Openbravo Issue Tracking System - Retail Modules
View Issue Details
0033985Retail ModulesWeb POSpublic2016-09-08 23:222016-09-26 23:20
guilleaer 
Retail 
highmajoralways
closedfixed 
5
 
RR16Q3.2RR16Q3.2 
guilleaer
No
0033985: 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.
blocks defect 0033933RR16Q4 closed guilleaer Docuemnt level taxes calculation fails when tax rate has decimals 
Issue History
2016-09-14 10:17marvintmTypedefect => backport
2016-09-14 10:17marvintmTarget VersionRR16Q4 => RR16Q3.2
2016-09-23 09:44hgbotCheckin
2016-09-23 09:44hgbotNote Added: 0090190
2016-09-23 09:44hgbotStatusscheduled => resolved
2016-09-23 09:44hgbotResolutionopen => fixed
2016-09-23 09:44hgbotFixed in SCM revisionhttp://code.openbravo.com/erp/pmods/org.openbravo.retail.posterminal/rev/847e6420c8a6551d9cc71dd951b8129e5539d68d [^] => http://code.openbravo.com/retail/backports/3.0RR16Q3.2/org.openbravo.retail.posterminal/rev/9d745a314bd7429611ee8dcdfab0d645dc5bed94 [^]
2016-09-26 23:20guilleaerReview Assigned To => guilleaer
2016-09-26 23:20guilleaerStatusresolved => closed
2016-09-26 23:20guilleaerFixed in Version => RR16Q3.2

Notes
(0090190)
hgbot   
2016-09-23 09:44   
Repository: retail/backports/3.0RR16Q3.2/org.openbravo.retail.posterminal
Changeset: 9d745a314bd7429611ee8dcdfab0d645dc5bed94
Author: Miguel de Juana <miguel.dejuana <at> openbravo.com>
Date: Fri Sep 23 09:44:04 2016 +0200
URL: http://code.openbravo.com/retail/backports/3.0RR16Q3.2/org.openbravo.retail.posterminal/rev/9d745a314bd7429611ee8dcdfab0d645dc5bed94 [^]

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

---
M web/org.openbravo.retail.posterminal/js/data/dataordertaxes.js
---