You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ofbiz.apache.org by "Anil K Patel (Jira)" <ji...@apache.org> on 2026/06/19 08:34:00 UTC

[jira] [Commented] (OFBIZ-224) Problem with approximations if the ShoppingCart.basePrice has more than three decimal digits.

    [ https://issues.apache.org/jira/browse/OFBIZ-224?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18090114#comment-18090114 ] 

Anil K Patel commented on OFBIZ-224:
------------------------------------

This issue is no longer reproducible in current trunk.

The root cause was floating-point arithmetic on `basePrice` and related price fields in `ShoppingCartItem`. This was resolved by the BigDecimal migration in commit *874f02e9da* (2009-01-06, David E. Jones):

> "Manual merge of typecheckcleanup200810 branch ... BigDecimal is now the native type for many entity fields and is used for many calculations"

`ShoppingCartItem.basePrice` is now declared as `private BigDecimal basePrice = BigDecimal.ZERO` (line 122). All cart calculations (`getItemSubTotal()`, etc.) use `BigDecimal.multiply()` and `BigDecimal.add()` — no floating-point rounding errors are possible.

Suggesting this issue be marked Resolved / Fixed.

> Problem with approximations if the ShoppingCart.basePrice has more than three decimal digits.
> ---------------------------------------------------------------------------------------------
>
>                 Key: OFBIZ-224
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-224
>             Project: OFBiz
>          Issue Type: Bug
>          Components: order
>            Reporter: Jacopo Cappellato
>            Priority: Major
>
> There is a problem with approximations if, in the ShoppingCartItem.basePrice field, a value with more than three decimal digits is set.
> This can happen mainly for two reasons:
> 1) the price in the ProductPrice entity has three decimal digits (it is now possible because that field is now of type currency-precise)
> 2) the base price is calculated from a price rule
> The problem is that, when the order is stored in the system, the unit price is approximated to two decimal digits (in OrderItem); unfortunately all the calculations (adjustments etc.) are performed with the original value with more than three decimal digits.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)