Anonymous | Login
Project:
RSS
  
News | My View | View Issues | Roadmap | Summary

View Issue DetailsJump to Notes ] Issue History ] Print ]
ID
0028514
TypeCategorySeverityReproducibilityDate SubmittedLast Update
defect[Retail Modules] Web POSmajoralways2015-01-02 11:522015-08-20 14:19
ReportermarvintmView Statuspublic 
Assigned Toadrianromero 
PrioritynormalResolutionfixedFixed in VersionRR15Q4
StatusclosedFix in branchFixed in SCM revision7bd79b3e4265
ProjectionnoneETAnoneTarget Version
OSAnyDatabaseAnyJava version
OS VersionDatabase versionAnt version
Product VersionSCM revision 
Review Assigned Tomarvintm
Regression level
Regression date
Regression introduced in release
Regression introduced by commit
Triggers an Emergency PackNo
Summary

0028514: Problem when calculating cascade taxes in price including taxes

DescriptionWhen prices are set with the tax included, the computation of taxes has a chance to produce a small rounding error. This happens due to the fact that a division is done over the total gross, to compute the tax amount and the net.

This, in turn, may create a situation in which the net plus the taxes do not sum the gross amount. The way this is handled is by adding the difference to the tax amount so that the sum is finally correct.

If several taxes affect the same line, the greatest tax is chosen to be rounded.

However, this approach has one main problem: the difference to be applied may be greater than the tax in which it is going to be applied, because it may come from different taxes. This problem is also exacerbated due to one change done several months ago, by which the tax chosen cannot be one defined as "cascade".

If the difference finally to be applied is greater than the tax in which it is applied, finally the result is that the tax amount ends up being negative, which is not correct.
Steps To Reproduce- Configure two different taxes for a product:
   * Tax 1: 8%. Cascade
   * Tax 2: 0%
- Configure the price for the product as 99.48 (including taxes).
- Create a ticket with two units of this product.
- Realize that the tax amount for tax 2 is -0.01. This is wrong.

Proposed SolutionThe solution which I propose (and is basically implemented in the attached patch) consists in rounding each tax individually, except of rounding one single tax in the end with the difference which comes from all taxes.

That is, just after computing tax 1 (which is cascade, and needs to be taken into account for tax 2), verify that net+tax is the expected gross. If it's not, round the tax so that it is, and then use this for the next tax.

This way, the differences are distributed between each tax, and therefore there cannot be a case in which we would need to reduce any given tax too much.
TagsNo tags attached.
Attached Filesdiff file icon issue28514.diff [^] (1,282 bytes) 2015-01-02 12:05 [Show Content]
diff file icon issue28514_erp.diff [^] (8,126 bytes) 2015-01-09 15:31 [Show Content]
diff file icon issue28514_pos1.diff [^] (3,453 bytes) 2015-01-09 15:32 [Show Content]
diff file icon issue28514_pos2.diff [^] (1,403 bytes) 2015-01-09 15:32 [Show Content]
diff file icon issue28514_pos3.diff [^] (1,019 bytes) 2015-01-09 15:32 [Show Content]

- Relationships Relation Graph ] Dependency Graph ]
related to defect 0027778RR14Q4 closedmarvintm Taxes are not being applied properly in Web POS with an specific configuration 

-  Notes
(0073291)
marvintm (manager)
2015-01-02 11:53

This problem has been reproduced in La Europea, but it should also be reproducible in any normal environment with cascade taxes, depending on the rates of such taxes (however, it's important to mention that it will probably not be common at all, because for it to happen the second tax needs to be a really small rate. The example in which it was reproduced had a zero rate, for example).
(0073292)
marvintm (manager)
2015-01-02 12:06

The patch attached to this issue seems to work but it needs further review before it is pushed.
(0073404)
adrianromero (manager)
2015-01-09 15:37
edited on: 2015-01-09 15:37

Attached diffs issue28514_erp.diff, issue28514_pos1.diff, issue28514_pos2.diff and issue28514_pos3.diff are the fixes delivered to La Europea. These fixes has been created on top of the "bomtaxes" proyect so it is possible that cannot be applied directly on the main branches of Openbravo.

The fixes contains the code changes for ERP (in PL/SQL) and POS (in javascript)

The implementation of the fix consists of applying the rounding adjustment on the greater tax amount independently on the taxbase, and it is ajusted not only the tax amount of the greater tax amount but also the base amount of son taxes.

(0078722)
hgbot (developer)
2015-07-08 08:55

Repository: erp/devel/pi
Changeset: 430198b3953a08264ff6e681236ba699c4be4933
Author: Adrián Romero <adrianromero <at> openbravo.com>
Date: Fri Jan 09 15:22:21 2015 +0100
URL: http://code.openbravo.com/erp/devel/pi/rev/430198b3953a08264ff6e681236ba699c4be4933 [^]

Fixes issue 0028514: Problem when calculating cascade taxes in price including taxes
Rounding adjustment is applied on greater tax amount independently on the taxbase, and it is ajusted the tax amount of the greater tax amount and the net of son taxes.
PL/SQL implementation

---
M src-db/database/model/functions/C_INVOICELINETAX_ROUNDING.xml
M src-db/database/model/functions/C_ORDERLINETAX_ROUNDING.xml
A src-db/database/model/functions/C_INVOICELINETAX_ROUNDING_AMT.xml
A src-db/database/model/functions/C_ORDERLINETAX_ROUNDING_AMT.xml
---
(0078735)
hgbot (developer)
2015-07-08 09:48

Repository: erp/pmods/org.openbravo.retail.posterminal
Changeset: 5fe614a6962edc37564683927d37094e272f9660
Author: Adrián Romero <adrianromero <at> openbravo.com>
Date: Thu Jan 08 13:50:39 2015 +0100
URL: http://code.openbravo.com/erp/pmods/org.openbravo.retail.posterminal/rev/5fe614a6962edc37564683927d37094e272f9660 [^]

Fixes issue 0028514: Problem when calculating cascade taxes in price including taxes
Rounding adjustment is applied on greater tax amount independently on the taxbase, and it is ajusted the tax amount of the greater tax amount and the net of son taxes.

---
M web/org.openbravo.retail.posterminal/js/data/dataordertaxes.js
---
(0078736)
hgbot (developer)
2015-07-08 09:48

Repository: erp/pmods/org.openbravo.retail.posterminal
Changeset: 2c381fa640a27d3c52dc6a5ca40abda2b96bd4c3
Author: Adrián Romero <adrianromero <at> openbravo.com>
Date: Thu Jan 08 15:39:03 2015 +0100
URL: http://code.openbravo.com/erp/pmods/org.openbravo.retail.posterminal/rev/2c381fa640a27d3c52dc6a5ca40abda2b96bd4c3 [^]

Fixes issue 0028514: Problem when calculating cascade taxes in price including taxes
Fixing mistakes in the logic

---
M web/org.openbravo.retail.posterminal/js/data/dataordertaxes.js
---
(0078737)
hgbot (developer)
2015-07-08 09:48

Repository: erp/pmods/org.openbravo.retail.posterminal
Changeset: 7bd79b3e42654b16fa645287a2cd5d88a1027871
Author: Adrián Romero <adrianromero <at> openbravo.com>
Date: Thu Jan 08 15:45:21 2015 +0100
URL: http://code.openbravo.com/erp/pmods/org.openbravo.retail.posterminal/rev/7bd79b3e42654b16fa645287a2cd5d88a1027871 [^]

Fixes issue 0028514: Problem when calculating cascade taxes in price including taxes
Updating copyright year in comments

---
M web/org.openbravo.retail.posterminal/js/data/dataordertaxes.js
---
(0078888)
adrianromero (manager)
2015-07-16 14:07

author Adrián Romero <adrianromero@openbravo.com>
Thu Jul 16 09:31:09 2015 +0200 (4 hours ago)
changeset 27136 8860b648abb2
parent 27135 8578a3f9632c
child 27137 07d1c9787148
BOM Taxes project
This commit contains all the BOM Taxes project that implements the calculation of taxes for BOM products

https://code.openbravo.com/erp/devel/pi/rev/8860b648abb2 [^] [^]


referencedata/sampledata/QA_Testing/C_INVOICE.xml
referencedata/sampledata/QA_Testing/C_INVOICELINE.xml
referencedata/sampledata/QA_Testing/C_TAX.xml
referencedata/sampledata/QA_Testing/C_TAXCATEGORY.xml
referencedata/sampledata/QA_Testing/C_TAXCATEGORY_TRL.xml
referencedata/sampledata/QA_Testing/C_TAX_ACCT.xml
referencedata/sampledata/QA_Testing/C_TAX_TRL.xml
referencedata/sampledata/QA_Testing/M_PRICELIST.xml
referencedata/sampledata/QA_Testing/M_PRICELIST_VERSION.xml
referencedata/sampledata/QA_Testing/M_PRODUCT.xml
referencedata/sampledata/QA_Testing/M_PRODUCTPRICE.xml
referencedata/sampledata/QA_Testing/M_PRODUCT_ACCT.xml
referencedata/sampledata/QA_Testing/M_PRODUCT_BOM.xml
src-db/database/model/functions/C_INVOICELINETAX_ROUNDING.xml
src-db/database/model/functions/C_INVOICELINETAX_ROUNDING_AMT.xml
src-db/database/model/functions/C_INVOICETAX_ROUNDING.xml
src-db/database/model/functions/C_INVOICE_POST.xml
src-db/database/model/functions/C_ORDERLINETAX_ROUNDING.xml
src-db/database/model/functions/C_ORDERLINETAX_ROUNDING_AMT.xml
src-db/database/model/functions/C_ORDERTAX_ROUNDING.xml
src-db/database/model/functions/C_ORDER_POST1.xml
src-db/database/model/functions/M_PROMOTION_CALCULATE.xml
src-db/database/model/tables/C_TAXCATEGORY.xml
src-db/database/model/tables/M_PRODUCT_BOM.xml
src-db/database/model/triggers/C_INVOICELINETAX_TRG.xml
src-db/database/model/triggers/C_INVOICELINE_BEFORE_TRG.xml
src-db/database/model/triggers/C_INVOICELINE_TRG2.xml
src-db/database/model/triggers/C_ORDERLINE_TRG.xml
src-db/database/model/triggers/C_ORDERLINE_TRG2.xml
src-db/database/sourcedata/AD_COLUMN.xml
src-db/database/sourcedata/AD_ELEMENT.xml
src-db/database/sourcedata/AD_FIELD.xml
src-test/src/org/openbravo/test/AllAntTaskTests.java
src-test/src/org/openbravo/test/costing/TestCosting.java
src-test/src/org/openbravo/test/taxes/TaxesTest.java
src-test/src/org/openbravo/test/taxes/data/BPartnerDataConstants.java
src-test/src/org/openbravo/test/taxes/data/ProductDataConstants.java
src-test/src/org/openbravo/test/taxes/data/TaxDataConstants.java
src-test/src/org/openbravo/test/taxes/data/TaxesTestData.java
src-test/src/org/openbravo/test/taxes/data/TaxesTestData1.java
src-test/src/org/openbravo/test/taxes/data/TaxesTestData10.java
src-test/src/org/openbravo/test/taxes/data/TaxesTestData11.java
src-test/src/org/openbravo/test/taxes/data/TaxesTestData12.java
src-test/src/org/openbravo/test/taxes/data/TaxesTestData13.java
src-test/src/org/openbravo/test/taxes/data/TaxesTestData14.java
src-test/src/org/openbravo/test/taxes/data/TaxesTestData15.java
src-test/src/org/openbravo/test/taxes/data/TaxesTestData16.java
src-test/src/org/openbravo/test/taxes/data/TaxesTestData17.java
src-test/src/org/openbravo/test/taxes/data/TaxesTestData18.java
src-test/src/org/openbravo/test/taxes/data/TaxesTestData19.java
src-test/src/org/openbravo/test/taxes/data/TaxesTestData2.java
src-test/src/org/openbravo/test/taxes/data/TaxesTestData20.java
src-test/src/org/openbravo/test/taxes/data/TaxesTestData21.java
src-test/src/org/openbravo/test/taxes/data/TaxesTestData22.java
src-test/src/org/openbravo/test/taxes/data/TaxesTestData23.java
src-test/src/org/openbravo/test/taxes/data/TaxesTestData24.java
src-test/src/org/openbravo/test/taxes/data/TaxesTestData25.java
src-test/src/org/openbravo/test/taxes/data/TaxesTestData26.java
src-test/src/org/openbravo/test/taxes/data/TaxesTestData27.java
src-test/src/org/openbravo/test/taxes/data/TaxesTestData28.java
src-test/src/org/openbravo/test/taxes/data/TaxesTestData29.java
src-test/src/org/openbravo/test/taxes/data/TaxesTestData3.java
src-test/src/org/openbravo/test/taxes/data/TaxesTestData30.java
src-test/src/org/openbravo/test/taxes/data/TaxesTestData31.java
src-test/src/org/openbravo/test/taxes/data/TaxesTestData32.java
src-test/src/org/openbravo/test/taxes/data/TaxesTestData33.java
src-test/src/org/openbravo/test/taxes/data/TaxesTestData34.java
src-test/src/org/openbravo/test/taxes/data/TaxesTestData4.java
src-test/src/org/openbravo/test/taxes/data/TaxesTestData5.java
src-test/src/org/openbravo/test/taxes/data/TaxesTestData6.java
src-test/src/org/openbravo/test/taxes/data/TaxesTestData7.java
src-test/src/org/openbravo/test/taxes/data/TaxesTestData8.java
src-test/src/org/openbravo/test/taxes/data/TaxesTestData9.java

- Issue History
Date Modified Username Field Change
2015-01-02 11:52 marvintm New Issue
2015-01-02 11:52 marvintm Assigned To => marvintm
2015-01-02 11:52 marvintm Triggers an Emergency Pack => No
2015-01-02 11:53 marvintm Note Added: 0073291
2015-01-02 12:05 marvintm File Added: issue28514.diff
2015-01-02 12:06 marvintm Note Added: 0073292
2015-01-02 14:38 marvintm Relationship added related to 0027778
2015-01-09 15:31 adrianromero Assigned To marvintm => adrianromero
2015-01-09 15:31 adrianromero File Added: issue28514_erp.diff
2015-01-09 15:32 adrianromero File Added: issue28514_pos1.diff
2015-01-09 15:32 adrianromero File Added: issue28514_pos2.diff
2015-01-09 15:32 adrianromero File Added: issue28514_pos3.diff
2015-01-09 15:37 adrianromero Note Added: 0073404
2015-01-09 15:37 adrianromero Note Edited: 0073404 View Revisions
2015-07-08 08:55 hgbot Checkin
2015-07-08 08:55 hgbot Note Added: 0078722
2015-07-08 08:55 hgbot Status new => resolved
2015-07-08 08:55 hgbot Resolution open => fixed
2015-07-08 08:55 hgbot Fixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/430198b3953a08264ff6e681236ba699c4be4933 [^]
2015-07-08 09:48 hgbot Checkin
2015-07-08 09:48 hgbot Note Added: 0078735
2015-07-08 09:48 hgbot Fixed in SCM revision http://code.openbravo.com/erp/devel/pi/rev/430198b3953a08264ff6e681236ba699c4be4933 [^] => http://code.openbravo.com/erp/pmods/org.openbravo.retail.posterminal/rev/5fe614a6962edc37564683927d37094e272f9660 [^]
2015-07-08 09:48 hgbot Checkin
2015-07-08 09:48 hgbot Note Added: 0078736
2015-07-08 09:48 hgbot Fixed in SCM revision http://code.openbravo.com/erp/pmods/org.openbravo.retail.posterminal/rev/5fe614a6962edc37564683927d37094e272f9660 [^] => http://code.openbravo.com/erp/pmods/org.openbravo.retail.posterminal/rev/2c381fa640a27d3c52dc6a5ca40abda2b96bd4c3 [^]
2015-07-08 09:48 hgbot Checkin
2015-07-08 09:48 hgbot Note Added: 0078737
2015-07-08 09:48 hgbot Fixed in SCM revision http://code.openbravo.com/erp/pmods/org.openbravo.retail.posterminal/rev/2c381fa640a27d3c52dc6a5ca40abda2b96bd4c3 [^] => http://code.openbravo.com/erp/pmods/org.openbravo.retail.posterminal/rev/7bd79b3e42654b16fa645287a2cd5d88a1027871 [^]
2015-07-16 14:07 adrianromero Note Added: 0078888
2015-08-17 14:40 shuehner Review Assigned To => marvintm
2015-08-20 14:19 marvintm Status resolved => closed
2015-08-20 14:19 marvintm Fixed in Version => RR15Q4


Copyright © 2000 - 2009 MantisBT Group
Powered by Mantis Bugtracker