Release Branch 16.11
OpenJDK 1.8.0_151 64bit on Ubuntu 16.04
After a discussion on the user mailinglist we concluded there seems to be an issue with the tax calculations.
Steps to reproduce
- Create a tax authority for a specific country (e.g. The Netherlands in my case)
- Set sales tax rate of 21% for your store with this Tax Authority
- Create a product and enter a price either including or excluding taxes and set the corresponding flag for tax included y/n.
- Go to the order manager and order entry. Fill in the details, select the product and go to the review page. It now shows the incorrect sales tax and price.
Let's say we have a product of 20 euro incl. taxes. With 21% that comes down to 3.47 euro of taxes and a price of 16.53 euro. Instead Ofbiz shows a price of 20 euro excl. taxes and adds 4.20 euros in taxes.
What I tried
Changing the price to price excl. VAT and set the flag to 'N' and visa versa. Both gave the same error.
I digged into the code and ended up in the file:
The function in line 2401
returns the price of one item there. It uses this piece of code:
The line item is always the price including taxes. When I adjust this price (by dividing it by 1.21) I do get the correct price in the review page. I do not, however, get the right tax amount. This is calculated elsewhere and still using the 20 euro price I guess. Anyway, it does show I was in the right spot.
I'm not familiar enough with Ofbiz to create a full patch, but I think the easiest way to go is to add another column to order items where the value excl. taxes is stored which can be used in places where needed. This does not affect the whole system. On the other hand I'm not sure where the order items are stored, since when you are on the review page it is not stored in database yet. Probably just in the session? Should make things even easier.
The attachments show an example. I have stored a product of 20 euro (screenshot directly taken from the database tool) and I have set-up a tax exempt in this case for a customer which shows 4.20 euro sales tax. If I turn off the tax exempt the grand total becomes 24.20 euros, so it is not related to the exempt.