[
https://issues.apache.org/jira/browse/OFBIZ-6436?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15759373#comment-15759373 ]
Scott Gray commented on OFBIZ-6436:
-----------------------------------
If I had then we would have seen a comment here discussing that review :-)
Rounding is a complicated issue and there have been numerous dev threads regarding it over the years. Just search the mailing lists for "rounding" and you'll see what I mean. At some point someone needs to review the whole lot and write up a document covering the OFBiz approach.
Until that happens we'll always have people coming in and wanting to make a specific fix for their specific situation, which in turn will break it for someone else and we get to carry on with this infinite feedback loop.
The only thing I have time to be concerned with right now is code review of any fixes that are brought forward.
Despite that, my quick thoughts are that Ingo is correct that the rounding of price rule calculations to 3dp may not be desirable for all users. But in saying that, a blanket configuration limiting unit prices to 2dp is also undesirable for anyone who does want greater than 2dp precision for unit prices. IMO it really needs to be configurable on a per product basis.
What is clear to me (based solely on Ingo's observation) is that there is a bug in the invoice item rounding. Invoice item amounts should not be rounded before multiplying against the quantity.
> Different price Order vs. Invoice due rounding
> ----------------------------------------------
>
> Key: OFBIZ-6436
> URL:
https://issues.apache.org/jira/browse/OFBIZ-6436> Project: OFBiz
> Issue Type: Bug
> Affects Versions: Release Branch 13.07, Release Branch 14.12, Trunk
> Reporter: Ingo Wolfmayr
> Assignee: Michael Brohl
> Attachments: priceservices.patch
>
>
> When creating an order with the following data, invoice and order calculates different prices due to different rounding strategies:
> Example:
> Net price: 8,70
> Price Rule: 2 %
> Calc price: 8,526
> Order quantity: 2
> Rounding order: 2 dec
> Rounding invoice: 2 dec
> Both: ROUND_HALF_UP
> Calculation for order price:
> 8,526 * 2 = 17,052 --> Rouning = 17,05 (rounding takes place after multipying with the order quantity )
> Calculation for invoice price:
> 8,53 * 2 = 17,06 (rounding takes place before multipying with the order quantity)
> Rounding takes place on different places and leads to (from my understanding) misscalculation.
> I create a patch that applies rounding on PriceCalculation level. Therefore:
> 1) get singe unit price and do all calculations on it (Price rules ...)
> 2) before forwarding the price, apply rounding (ORDER SETTINGS) on single unit price
> As the invoice calculation uses the unit price (if invoice is associate with order) from ORDER_ITEM it will calculate with the already rounded value.
> Result: Order Price = Invoice Price
> I would appreciate any thought on it.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)