Receive offline payment (May be the Entity Engine) has decimal precision problem
--------------------------------------------------------------------------------

                 Key: OFBIZ-2833
                 URL: https://issues.apache.org/jira/browse/OFBIZ-2833
             Project: OFBiz
          Issue Type: Bug
          Components: framework, order
    Affects Versions: Release Branch 9.04, SVN trunk
         Environment: The Database I'm used for testing is the built in Derby. 
I'm not sure if other DBMS has same problem.
            Reporter: Miles Huang


Reproduce the problem is simple. In Order Manager Application, simply enter an 
offline payment for a sales order with amount $65.30, the payment amount stored 
in the DB will change to $65.29.
Digging into the code, in the 
org.ofbiz.order.OrderManagerEvents.receiveOfflinePayment method, although the 
passed in amountStr is "65.30", the parsed out BigDecimal paymentTypeAmount 
have value "65.2999999999999971578290569595992565155029296875". Checking the 
payment amount stored in the Payments entity use web tools, the result is 
65.29. And the order still has $0.01 outstanding amount.
Parse the BigDecimal value from string directly may solve the problem 
partially. But imagine if someone enters $65.299, the problem is still there.
Or a better and safe solution, in Entity Engine, always round half up 
BigDecimal value to the same precision as the corresponding DB column before 
insert/update?


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

Reply via email to