Openbravo Issue Tracking System - Retail Modules
View Issue Details
0033933Retail ModulesWeb POSpublic2016-09-08 23:222018-07-27 15:33
guilleaer 
guilleaer 
highmajoralways
closedfixed 
5
 
RR16Q4 
marvintm
No
0033933: Docuemnt level taxes calculation fails when tax rate has decimals
Document level tax calculations done by web POS are wrong when the tax rate has decimals.

It happens because the algorithm is rounding earlier than expected.
Create a tax with a rate of 21.5 (you can modify ENTREGAS IVA 21% rate's)
Open web POS in a terminal using price not including taxes
Add a product
 - Avalanche Transceiver (150.50)
Realize that taxes calculations are wrong
 - Tax amount is 27.14 but it should be 26.63
 - Net should be 123.87 but it is 123.36

This happens because when executing the algorithm, we are rounding.
In this case, the algorithm first calculates the total gross 150.5
Then the net is recalculated with the following expression:

newNet = round(totalGross / (1+rate))

The problem is that wrongly we are doing the following

newNet = round(totalGross / round(1+rate))

So in this particular case, newNet calculation is wrong:

wrong -> newNet = round(150.5 / round(1+0.215))
wrong -> newNet = round(150.5 / 1+1.22)
wrong -> newNet = round(123.3606557) -> 123.36
correct -> newNet = round(150.5 / 1+1.215)
correct -> newNet = round(123.8683128) -> 123.87

Because tax amount is based on net, it is also wrong
taxamount = total - newNet

Wrong -> 150.5 - 123.36 = 27.14
Correct -> 150.5 - 123.87 = 26.63
round in the correct place when net is being calculated

do
newNet = round(totalGross / (1+rate))
instead of
newNet = round(totalGross / round(1+rate))
No tags attached.
depends on backport 0033985RR16Q3.2 closed Retail Docuemnt level taxes calculation fails when tax rate has decimals 
depends on backport 0033986RR16Q2.3 closed Retail Docuemnt level taxes calculation fails when tax rate has decimals 
related to defect 0034084 new Retail Pending test to be developed 
diff roundingrate.diff (803) 2016-09-08 23:34
https://issues.openbravo.com/file_download.php?file_id=9797&type=bug
Issue History
2016-09-08 23:22guilleaerNew Issue
2016-09-08 23:22guilleaerAssigned To => Retail
2016-09-08 23:22guilleaerTriggers an Emergency Pack => No
2016-09-08 23:34guilleaerFile Added: roundingrate.diff
2016-09-09 00:15guilleaerNote Added: 0089859
2016-09-09 15:50hgbotCheckin
2016-09-09 15:50hgbotNote Added: 0089873
2016-09-09 15:50hgbotStatusnew => resolved
2016-09-09 15:50hgbotResolutionopen => fixed
2016-09-09 15:50hgbotFixed in SCM revision => http://code.openbravo.com/erp/pmods/org.openbravo.retail.posterminal/rev/847e6420c8a6551d9cc71dd951b8129e5539d68d [^]
2016-09-09 15:50guilleaerStatusresolved => new
2016-09-09 15:50guilleaerResolutionfixed => open
2016-09-09 15:51guilleaerNote Added: 0089874
2016-09-09 15:51guilleaerNote Deleted: 0089859
2016-09-14 10:17marvintmStatusnew => scheduled
2016-09-16 14:40marvintmStatusscheduled => resolved
2016-09-16 14:40marvintmResolutionopen => fixed
2016-09-19 09:20marvintmAssigned ToRetail => guilleaer
2016-09-26 10:42guilleaerRelationship addedrelated to 0034084
2016-09-26 11:53marvintmReview Assigned To => marvintm
2016-09-26 11:53marvintmStatusresolved => closed
2018-07-27 15:33hgbotCheckin
2018-07-27 15:33hgbotNote Added: 0105991

Notes
(0089873)
hgbot   
2016-09-09 15:50   
Repository: erp/pmods/org.openbravo.retail.posterminal
Changeset: 847e6420c8a6551d9cc71dd951b8129e5539d68d
Author: Guillermo Alvarez de Eulate <guillermo.alvarez <at> openbravo.com>
Date: Thu Sep 08 23:59:10 2016 +0200
URL: http://code.openbravo.com/erp/pmods/org.openbravo.retail.posterminal/rev/847e6420c8a6551d9cc71dd951b8129e5539d68d [^]

Fixed issue 33933: Round in proper place when document taxes are calculated

---
M web/org.openbravo.retail.posterminal/js/data/dataordertaxes.js
---
(0089874)
guilleaer   
2016-09-09 15:51   
Fix has passed try
Issue reopened because test is pending
(0105991)
hgbot   
2018-07-27 15:33   
Repository: tools/automation/pi-mobile
Changeset: 8efea16e85430c3aa409bf5bc96e8b35f21ce086
Author: Alejandro <alekosmp86 <at> gmail.com>
Date: Mon Jul 23 14:51:46 2018 -0400
URL: http://code.openbravo.com/tools/automation/pi-mobile/rev/8efea16e85430c3aa409bf5bc96e8b35f21ce086 [^]

Related to issue 33933: added automated test

---
A src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/sales/taxes/I33933_VerifyDocumentLevelTaxesCalculation.java
---