Invoice: tax calculatios has an error

  • Posts: 86
  • Thank you received: 2
10 years 10 months ago #135499

-- url of the page with the problem -- : mywebsite.com/mypage
-- HikaShop version -- : 2.2.2
-- Joomla version -- : 2.5.14

Hi,
I observed an error in the invoice which is causen when "Round prices during calculations" is set to "Yes".
The error also ocurrs when I use the defauld invoice.php file.

It seems that the invoice is currently calculated like in this example:
8,26440 x 21% = 1,7355=1,74

The correct way would be to use 3,00 as base.
8,26 x 21% = 1,7346=1,73

What do I need to modify to fix this error?

Best Regards,
Hannes

p.s: I thins this was my last question in order to finish the online shop. :P

Last edit: 10 years 10 months ago by scharfet.

Please Log in or Create an account to join the conversation.

  • Posts: 86
  • Thank you received: 2
10 years 10 months ago #135513

Hi,

I just observed that this error allready ocurrs on checkout, so it has nothing to do with the invoice as I thought at the beginning.

Last edit: 10 years 10 months ago by scharfet.

Please Log in or Create an account to join the conversation.

  • Posts: 86
  • Thank you received: 2
10 years 10 months ago #135516

Hello!

I know now that the error comes from modifications which was made.

Please could you tell me which php file deals with the calculation of the tax?

Thank you for your help.

Please Log in or Create an account to join the conversation.

  • Posts: 82723
  • Thank you received: 13338
  • MODERATOR
10 years 10 months ago #135541

Which modifications are you talking about ?

The tax calculations are all done in the file administrator/components/com_hikashop/classes/currency.php

Please Log in or Create an account to join the conversation.

  • Posts: 86
  • Thank you received: 2
10 years 10 months ago #135573

Hi Nicolas,

I use the original file administrator/components/com_hikashop/classes/currency.php and I have removed all overrides of the hikashop views, but the tax is still not calculated correctly. I do not know what to do.

I made a test. I created the same prouct and same tax on demo.hikashop.com. On your demo shop the tax is calculated correctly.

Please Log in or Create an account to join the conversation.

  • Posts: 86
  • Thank you received: 2
10 years 10 months ago #135576

Hi Nicolas,

I just found out that your demo shop has the same error.





I would thank you if you could inform me how to fix the error or send me the updated file so I can repace it.

Best regards

Last edit: 10 years 10 months ago by scharfet.

Please Log in or Create an account to join the conversation.

  • Posts: 82723
  • Thank you received: 13338
  • MODERATOR
10 years 10 months ago #135605

I don't understand how you get that.
Here are my results on the demo website:


That is without calculations rounding.
The price of the product is €8.3612
When you multiply by 10, it's €83.612
Then you add the taxes (19.6%) on it: 99.999952 which is then rounded to €100
The taxes are: 99.999952-83.612=16.387952 which is then rounded to €16.39
So these calculations are perfectly correct.


That is with the calculations rounding.
The price of the product is €8.3612
When you multiply by 10, it's €83.612 rounded to €83.61
Then you add the taxes (19.6%) on it: 99.99756 which is then rounded to €100
The taxes are: 100-10*8.36=16.40
So these calculations are perfectly correct too.

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 86
  • Thank you received: 2
10 years 10 months ago #136436

Hello Nicolas.

sorry for forgetting to tell you that the error ocurred when VAT is set to 21% (instead of 19,6%).

I made some more tests using your demo shop. This time I just modified the net price of a certain product.
I observed differences in the calculations when "Round prices during calculations" si set to Yes or No.

Please see the attached excel file or the image to see the results of my tests. The file shows the results of the calculations in the cart of your demo shop
I am not quite sure when the error ocurrs. Some tims the tax amount shows an error, and some times it is the total amount which has the error.
I hope this helps to identify the cause.



Thank you!

Last edit: 10 years 10 months ago by scharfet.

Please Log in or Create an account to join the conversation.

  • Posts: 86
  • Thank you received: 2
10 years 10 months ago #136949

If you creade products using one of the "net procuct price" displayed in the screenshot and add 10 of these products into the cart you will be able to reproduce the error.

I hope you can fix this error.

Best,
Hannes

Please Log in or Create an account to join the conversation.

  • Posts: 82723
  • Thank you received: 13338
  • MODERATOR
10 years 10 months ago #137395

Again, I don't see the problem with your tests:
The price of the product is €8,26447 (there are 5 decimals saved in HikaShop so that's what becomes €8,264465)
When you multiply by 10, it's €82,6447
Then you add the taxes (21%) on it: 100,000087 which is then rounded to €100
The taxes are: 100,000087-82,6447=17,355387 which is then rounded to €17,36

The price of the product is €8,26447 rounded to €8,26
Then you add the taxes (21%) on it: €9,9946 which is then rounded to €10
When you multiply by 10, it's €100
The taxes are: 100-10*8.26=17.40
So these calculations are perfectly correct too.

I still don't see what you want me to fix as so far all the examples I tried from you worked out properly.

Please Log in or Create an account to join the conversation.

Time to create page: 0.084 seconds
Powered by Kunena Forum