OFBiz
  1. OFBiz
  2. OFBIZ-4038

Rounding error in prorating returned adjustments

    Details

      Description

      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

        Activity

        Hide
        Jacques Le Roux added a comment -

        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.

        Show
        Jacques Le Roux added a comment - 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.
        Hide
        Jacques Le Roux added a comment -

        Jeremy,

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

        Show
        Jacques Le Roux added a comment - Jeremy, My apologies, the rounding was already present in the divide operation, so the additional setScale wasn't necessary.

          People

          • Assignee:
            Jacques Le Roux
            Reporter:
            Wickersheimer Jeremy
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development