You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ofbiz.apache.org by "Wickersheimer Jeremy (JIRA)" <ji...@apache.org> on 2010/11/29 11:55:40 UTC

[jira] Created: (OFBIZ-4038) Rounding error in prorating returned adjustments

Rounding error in prorating returned adjustments
------------------------------------------------

                 Key: OFBIZ-4038
                 URL: https://issues.apache.org/jira/browse/OFBIZ-4038
             Project: OFBiz
          Issue Type: Bug
    Affects Versions: Release 09.04, Release Branch 09.04, Release Branch 10.04
            Reporter: Wickersheimer Jeremy
            Priority: Minor


The error is in applications/order/src/org/ofbiz/order/order/OrderReturnServices.java the getAdjustmentAmount method is prorating using this code: 

newAmount = returnTotal.divide(originalTotal, decimals, rounding).multiply(amount).setScale(decimals, rounding);

it should be:

newAmount = returnTotal.multiply(amount).divide(originalTotal, decimals, rounding);

else by dividing first what should be for example 1/3 of the adjustment ends up being 0.33

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


[jira] Commented: (OFBIZ-4038) Rounding error in prorating returned adjustments

Posted by "Jacques Le Roux (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OFBIZ-4038?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12966819#action_12966819 ] 

Jacques Le Roux commented on OFBIZ-4038:
----------------------------------------

Jeremy,

My apologies, the rounding was already present in the divide operation, so the additional setScale wasn't necessary.



> Rounding error in prorating returned adjustments
> ------------------------------------------------
>
>                 Key: OFBIZ-4038
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-4038
>             Project: OFBiz
>          Issue Type: Bug
>    Affects Versions: Release Branch 09.04, Release 09.04, Release Branch 10.04
>            Reporter: Wickersheimer Jeremy
>            Assignee: Jacques Le Roux
>            Priority: Minor
>             Fix For: Release Branch 09.04, Release Branch 10.04, SVN trunk
>
>
> The error is in applications/order/src/org/ofbiz/order/order/OrderReturnServices.java the getAdjustmentAmount method is prorating using this code: 
> newAmount = returnTotal.divide(originalTotal, decimals, rounding).multiply(amount).setScale(decimals, rounding);
> it should be:
> newAmount = returnTotal.multiply(amount).divide(originalTotal, decimals, rounding);
> else by dividing first what should be for example 1/3 of the adjustment ends up being 0.33

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


[jira] Closed: (OFBIZ-4038) Rounding error in prorating returned adjustments

Posted by "Jacques Le Roux (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OFBIZ-4038?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jacques Le Roux closed OFBIZ-4038.
----------------------------------

       Resolution: Fixed
    Fix Version/s: SVN trunk
                   Release Branch 10.04
                   Release Branch 09.04
         Assignee: Jacques Le Roux

Thanks Jeremy,

Your suggested change is trunk at r1042034 ,R10.04 at r1042036, R9.04 at r1042037

It may seem obvious, but I would just have preferred that you would not have omited the setScale part. :p

> Rounding error in prorating returned adjustments
> ------------------------------------------------
>
>                 Key: OFBIZ-4038
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-4038
>             Project: OFBiz
>          Issue Type: Bug
>    Affects Versions: Release Branch 09.04, Release 09.04, Release Branch 10.04
>            Reporter: Wickersheimer Jeremy
>            Assignee: Jacques Le Roux
>            Priority: Minor
>             Fix For: Release Branch 09.04, Release Branch 10.04, SVN trunk
>
>
> The error is in applications/order/src/org/ofbiz/order/order/OrderReturnServices.java the getAdjustmentAmount method is prorating using this code: 
> newAmount = returnTotal.divide(originalTotal, decimals, rounding).multiply(amount).setScale(decimals, rounding);
> it should be:
> newAmount = returnTotal.multiply(amount).divide(originalTotal, decimals, rounding);
> else by dividing first what should be for example 1/3 of the adjustment ends up being 0.33

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