You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ofbiz.apache.org by "Miles Huang (JIRA)" <ji...@apache.org> on 2009/08/15 20:05:14 UTC

[jira] Created: (OFBIZ-2833) Receive offline payment (May be the Entity Engine) has decimal precision problem

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.


[jira] Closed: (OFBIZ-2833) Receive offline payment (May be the Entity Engine) has decimal precision problem

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

Scott Gray closed OFBIZ-2833.
-----------------------------

       Resolution: Fixed
    Fix Version/s: SVN trunk
         Assignee: Scott Gray

Using ObjectType.simpleTypeConvert seems to fix the issue, committed in r813232.  Thanks for the detailed report Miles.

> 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
>            Assignee: Scott Gray
>             Fix For: SVN trunk
>
>
> 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.


[jira] Commented: (OFBIZ-2833) Receive offline payment (May be the Entity Engine) has decimal precision problem

Posted by "David E. Jones (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OFBIZ-2833?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12753212#action_12753212 ] 

David E. Jones commented on OFBIZ-2833:
---------------------------------------

Based on the description this doesn't sound like a database problem, but rather a problem where rounding is missing in the code. My guess is that this would happen on any database... just based on the description thought, I haven't tested it.

> 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.


[jira] Commented: (OFBIZ-2833) Receive offline payment (May be the Entity Engine) has decimal precision problem

Posted by "Scott Gray (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OFBIZ-2833?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12753418#action_12753418 ] 

Scott Gray commented on OFBIZ-2833:
-----------------------------------

The problem is right here:
{code}
paymentTypeAmount = new BigDecimal(NumberFormat.getNumberInstance(locale).parse(amountStr).doubleValue());
{code}

what we need is a better way to parse a localized amount into a BigDecimal that doen't require an intermediate double.

> 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.


[jira] Commented: (OFBIZ-2833) Receive offline payment (May be the Entity Engine) has decimal precision problem

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

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

I checked this problem does not exist in PostGres (8.3). I suggest to close this issue as Derby is not our recommenced DBMS for production, PostGres is. Any other opinions ?

> 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.


[jira] Commented: (OFBIZ-2833) Receive offline payment (May be the Entity Engine) has decimal precision problem

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

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

At least it's ok with postgres

> 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.


[jira] Commented: (OFBIZ-2833) Receive offline payment (May be the Entity Engine) has decimal precision problem

Posted by "Miles Huang (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OFBIZ-2833?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12753414#action_12753414 ] 

Miles Huang commented on OFBIZ-2833:
------------------------------------

May I suggest if someone familiar with JDBC specification can check this problem?
If the JDBC specification has clarified that the JDBC driver should do the number round operation in round half up mode, then its okay that OFBiz relies on the JDBC specification to do the round operation. This issue could be considered as a Derby bug.
Otherwise, may we still consider this is an OFBiz bug? Although this bug condition will not be triggered on some specific kinds of DB, it may be triggered by others, may be someday in the future.

Best Regards,
Miles.





> 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.