Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0035486Openbravo ERP09. Financial managementpublic2017-03-10 15:372017-03-20 15:18
adrianromero 
aferraz 
urgentmajorhave not tried
closedfixed 
5
 
3.0PR17Q2 
vmromanos
Core
No
0035486: [SER-QA 2587] Taxes at document level are rounded in a different way in WebPOS and Backend
With a tax rate calculated at document level of 20% and a total order of 357.99, The problem it is a difference in rounding between ERP and POS when calculating the total net.

POS rounds 298,325 to 298.33. Round half up?
ERP rounds 298.325 to 298.32. Round half down? Round half to even?

It has to be determined what is the right rounding calculation.
In description. See attached images.
SER-QA
related to design defect 0032265 closed aferraz [SER QA 1434] Taxes at document level are not properly calculated in some cases 
png Captura de pantalla de 2017-03-10 15:39:14.png (165,873) 2017-03-10 15:40
https://issues.openbravo.com/file_download.php?file_id=10552&type=bug
png

png Captura de pantalla de 2017-03-10 15:38:58.png (144,352) 2017-03-10 15:41
https://issues.openbravo.com/file_download.php?file_id=10553&type=bug
png
Issue History
2017-03-10 15:37adrianromeroNew Issue
2017-03-10 15:37adrianromeroAssigned To => Retail
2017-03-10 15:37adrianromeroResolution time => 1490310000
2017-03-10 15:37adrianromeroTriggers an Emergency Pack => No
2017-03-10 15:40adrianromeroTag Attached: SER-QA
2017-03-10 15:40adrianromeroFile Added: Captura de pantalla de 2017-03-10 15:39:14.png
2017-03-10 15:41adrianromeroFile Added: Captura de pantalla de 2017-03-10 15:38:58.png
2017-03-10 15:41adrianromeroSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=14771#r14771
2017-03-10 15:42adrianromeroRelationship addedrelated to 0032265
2017-03-10 15:51adrianromeroDescription Updatedbug_revision_view_page.php?rev_id=14773#r14773
2017-03-13 10:17aferrazAssigned ToRetail => aferraz
2017-03-13 11:06aferrazProjectRetail Modules => Openbravo ERP
2017-03-13 11:06aferrazModules => Core
2017-03-13 11:06aferrazCategoryWeb POS => 09. Financial management
2017-03-13 16:12vmromanosStatusnew => scheduled
2017-03-15 16:39hgbotCheckin
2017-03-15 16:39hgbotNote Added: 0095055
2017-03-15 16:39hgbotStatusscheduled => resolved
2017-03-15 16:39hgbotResolutionopen => fixed
2017-03-15 16:39hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/8281d757d8ba02c6a948f36b6ec358948cfbdb1c [^]
2017-03-15 16:39hgbotCheckin
2017-03-15 16:39hgbotNote Added: 0095056
2017-03-16 16:34hudsonbotCheckin
2017-03-16 16:34hudsonbotNote Added: 0095334
2017-03-16 16:34hudsonbotCheckin
2017-03-16 16:34hudsonbotNote Added: 0095335
2017-03-20 15:18vmromanosReview Assigned To => vmromanos
2017-03-20 15:18vmromanosNote Added: 0095430
2017-03-20 15:18vmromanosStatusresolved => closed
2017-03-20 15:18vmromanosFixed in Version => 3.0PR17Q2

Notes
(0095055)
hgbot   
2017-03-15 16:39   
Repository: erp/devel/pi
Changeset: 8281d757d8ba02c6a948f36b6ec358948cfbdb1c
Author: Alvaro Ferraz <alvaro.ferraz <at> openbravo.com>
Date: Wed Mar 15 14:36:31 2017 +0100
URL: http://code.openbravo.com/erp/devel/pi/rev/8281d757d8ba02c6a948f36b6ec358948cfbdb1c [^]

Fixes issue 35486: Net Amount not properly rounded in ERP with PostgreSQL

Problem was in following calculation: Net Amount = Gross Amount * (Gross Amount / (Gross Amount + Tax Amount)).
In case Gross Amount = 357.99 and Tax Amount = 71.598, Net Amount = 357.99 * (357.99 / (357.99 + 71.598)) = 298.325.

It was correct in Oracle as it retrieves 298.325 but it was failing in PostgreSQL as it retrieves 298.3249999999999999988067:
SELECT 357.99 * (357.99 / (357.99 + 71.598)) FROM dual;

If we do multiplication before division, we avoid this problem and both PostgreSQL and Oracle retrieves the correct result (298.325):
SELECT (357.99 * 357.99) / (357.99 + 71.598) FROM dual;

---
M src-db/database/model/functions/C_GET_NET_AMOUNT_FROM_GROSS.xml
M src-db/database/model/functions/C_GET_NET_PRICE_FROM_GROSS.xml
---
(0095056)
hgbot   
2017-03-15 16:39   
Repository: erp/devel/pi
Changeset: bb77b1e335cbcf1c3d208b706f830fb41cfec3d2
Author: Alvaro Ferraz <alvaro.ferraz <at> openbravo.com>
Date: Wed Mar 15 14:54:07 2017 +0100
URL: http://code.openbravo.com/erp/devel/pi/rev/bb77b1e335cbcf1c3d208b706f830fb41cfec3d2 [^]

Related to issue 35486: Add some automated tests

---
M src-test/src/org/openbravo/test/taxes/TaxesTest.java
A src-test/src/org/openbravo/test/taxes/data/TaxesTestData161.java
A src-test/src/org/openbravo/test/taxes/data/TaxesTestData162.java
A src-test/src/org/openbravo/test/taxes/data/TaxesTestData163.java
A src-test/src/org/openbravo/test/taxes/data/TaxesTestData164.java
A src-test/src/org/openbravo/test/taxes/data/TaxesTestData165.java
A src-test/src/org/openbravo/test/taxes/data/TaxesTestData166.java
A src-test/src/org/openbravo/test/taxes/data/TaxesTestData167.java
A src-test/src/org/openbravo/test/taxes/data/TaxesTestData168.java
A src-test/src/org/openbravo/test/taxes/data/TaxesTestData169.java
A src-test/src/org/openbravo/test/taxes/data/TaxesTestData170.java
A src-test/src/org/openbravo/test/taxes/data/TaxesTestData171.java
A src-test/src/org/openbravo/test/taxes/data/TaxesTestData172.java
A src-test/src/org/openbravo/test/taxes/data/TaxesTestData173.java
A src-test/src/org/openbravo/test/taxes/data/TaxesTestData174.java
A src-test/src/org/openbravo/test/taxes/data/TaxesTestData175.java
A src-test/src/org/openbravo/test/taxes/data/TaxesTestData176.java
A src-test/src/org/openbravo/test/taxes/data/TaxesTestData177.java
A src-test/src/org/openbravo/test/taxes/data/TaxesTestData178.java
A src-test/src/org/openbravo/test/taxes/data/TaxesTestData179.java
A src-test/src/org/openbravo/test/taxes/data/TaxesTestData180.java
A src-test/src/org/openbravo/test/taxes/data/TaxesTestData181.java
A src-test/src/org/openbravo/test/taxes/data/TaxesTestData182.java
A src-test/src/org/openbravo/test/taxes/data/TaxesTestData183.java
A src-test/src/org/openbravo/test/taxes/data/TaxesTestData184.java
---
(0095334)
hudsonbot   
2017-03-16 16:34   
A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/41ab6f71c85b [^]
Maturity status: Test
(0095335)
hudsonbot   
2017-03-16 16:34   
A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/41ab6f71c85b [^]
Maturity status: Test
(0095430)
vmromanos   
2017-03-20 15:18   
Code review + testing OK