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 (JIRA)" <ji...@apache.org> on 2007/09/30 22:56:50 UTC

[jira] Updated: (OFBIZ-249) Re-factor BigDecimal calculations

     [ https://issues.apache.org/jira/browse/OFBIZ-249?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jacques Le Roux updated OFBIZ-249:
----------------------------------

    Component/s: pos

> Re-factor BigDecimal calculations
> ---------------------------------
>
>                 Key: OFBIZ-249
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-249
>             Project: OFBiz
>          Issue Type: Bug
>          Components: accounting, order, pos
>            Reporter: Jacopo Cappellato
>            Assignee: Jacques Le Roux
>
> Copy of a set of related issues created in the old server by Si (and others):
>  1. In applications/accounting/src/ re-factor to use arithmetic.properties instead of
> 2. Per comments of Bradley Plies,
> The following files have something like:
>  ... = new BigDecimal("0");
> \applications\accounting\src\org\ofbiz\accounting
>    \invoice\InvoiceServices.java (11 matches)
>    \invoice\InvoiceWorker.java (4 matches)
>    \payment\PaymentWorker.java
>    \tax\TaxAuthorityServices.java
> \applications\accounting\webapp\accounting\WEB-INF\actions\invoice\createItemList.bsh (4 matches)
> \applications\order\src\org\ofbiz\order
>    \order\OrderReadHelper.java
>    \order\OrderReturnServices.java
>    \shoppingcart\CheckOutHelper.java
> However BigDecimal already provides a constant BigDecimal.ZERO (as well as BigDecimal.ONE which are both inherited from superclass BigInteger) such that doing this is unnecessary (but not incorrect) and just creates more objects. The scale of the mathematical results will not be unaffected, as described in the JDK. http://java.sun.com/j2se/1.4.2/docs/api/java/math/BigDecimal.html
>  All  	 Comments  	 Work Log  	 Change History  	  	  Sort Order: [navigator.ascending.order]
> Comment by Leon Torres [08/Mar/06 12:33 PM]
> [ Permlink ]
> There is no BigDecimal.ZERO. I tried compiling, got an error, looked at the javadoc and realized it is only BigInteger.ZERO. We're better off setting a static ZERO ourselves somewhere, preferably at the top of the Java file along with the scale and rounding mode.
> Look at InvoiceServices.java for example. Also, I was setting the scale of zero out of paranoia in that code, it probably isn't necessary. 
> ===================================================
> Re-factor the following to use arithmetic.properties instead of setting them directly:
> org/ofbiz/accounting/tax/TaxAuthorityServices.java: taxTotal.setScale(2, BigDecimal.ROUND_CEILING);
> org/ofbiz/accounting/tax/TaxAuthorityServices.java: priceWithTax.setScale(2, BigDecimal.ROUND_CEILING);
> org/ofbiz/accounting/invoice/InvoiceWorker.java: invoiceTotal = invoiceTotal.add( amount.multiply(quantity)).setScale(2,4);

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.