Please help us to make AbanteCart Ideal Open Source Ecommerce Solution for everyone.

Support AbanteCart eCommerce

Author Topic: function round tax is wrong  (Read 5258 times)

Offline legrand

  • Newbie
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
function round tax is wrong
« on: August 01, 2017, 05:05:34 PM »
hi, i'm discover AbanteCart and i play with before 2 weeks, its seem perfect but
i've a difference of 0.01 on tax, for 2 products at 4.90 inc tax of 5.5% (tax= 0.26), AbanteCart cart calculate tax 0.51 and total 9.79!!  why not 0.52 and 9.80??
and why if i turn ON "display price with tax" and OFF "estimate shipping" option, the same product was displayed 4.64 inc tax? (not logged, cache cleared and store location was correct).

thanks
sorry for typing errors!

(i have read all the good docs but? ;)

Offline Basara

  • Administrator
  • Hero Member
  • *****
  • Posts: 5810
  • Karma: +274/-2
    • View Profile
Re: function round tax is wrong
« Reply #1 on: August 02, 2017, 01:16:20 AM »
2 products at 4.90 inc tax

What is the price of product set in admin?

Offline Basara

  • Administrator
  • Hero Member
  • *****
  • Posts: 5810
  • Karma: +274/-2
    • View Profile
Re: function round tax is wrong
« Reply #2 on: August 02, 2017, 01:17:26 AM »

and why if i turn ON "display price with tax" and OFF "estimate shipping" option, the same product was displayed 4.64 inc tax? (not logged, cache cleared and store location was correct).

When you set "estimate shipping" to off it just disable Estimate block on the shopping cart page

Offline legrand

  • Newbie
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: function round tax is wrong
« Reply #3 on: August 02, 2017, 04:58:10 AM »
2 products at 4.90 inc tax

What is the price of product set in admin?

4.64 in admin

Offline legrand

  • Newbie
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: function round tax is wrong
« Reply #4 on: August 02, 2017, 05:19:12 AM »

and why if i turn ON "display price with tax" and OFF "estimate shipping" option, the same product was displayed 4.64 inc tax? (not logged, cache cleared and store location was correct).

When you set "estimate shipping" to off it just disable Estimate block on the shopping cart page

When i set "estimate shipping" to off and no logged, all products prices are without tax but display inc tax, and on shopping cart page and block cart in header show sub total and total are same. (9.28=2x 4.64)
When i set "estimate shipping" to off and i'm logging, all products prices are with tax, but on shopping cart page sub total and total are same. (9.28=2x 4.64)

thanks

Offline Basara

  • Administrator
  • Hero Member
  • *****
  • Posts: 5810
  • Karma: +274/-2
    • View Profile
Re: function round tax is wrong
« Reply #5 on: August 02, 2017, 05:22:58 AM »
Thank you.

For the 'estimate' off - looks like bug. If no tax applied should not be 'inc tax'.

For the price calculation

4.64 + 5.5 % (0.2552) = 4.8952 x 2 = 9.7904

4.90 is rounded value for display only from 4.8952 (..52 - 3 digits)

so 9.79 is rounded for calculation from  9.7904 (...4 digits)

Why you think it should be 9.80?

Offline legrand

  • Newbie
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: function round tax is wrong
« Reply #6 on: August 02, 2017, 05:57:35 AM »
ok i understood the problem,

but it's same result when i set 4.6445 (4.90/1.055) in admin,

4.6445 x 2 = 9.2890
9.2890 x 1.055 (for tax 5.5%) = 9.7988

how to calculate with 4 digits and display round total to 9.80?

my price must be displayed with tax in france.
so when a customer take 2 x 4.90 product, the total should be 9.80, no?

« Last Edit: August 02, 2017, 06:03:48 AM by legrand »

Offline abantecart

  • Administrator
  • Hero Member
  • *****
  • Posts: 4359
  • Karma: +298/-10
    • View Profile
    • Ideal Open Source Ecommerce Solution
Re: function round tax is wrong
« Reply #7 on: August 02, 2017, 10:16:05 AM »
Please  rate your experience or leave your review
We need your help to build better free open source ecommerce platform for everyone. See how you can help

Offline legrand

  • Newbie
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: function round tax is wrong
« Reply #8 on: August 03, 2017, 05:30:11 AM »
hi, ok but how to round price sub total to 2 decimal after it is multiplied by qty?

for display that, for example if i buy 2 products 4.90 with 5.5% (4.6445 in admin):
sub total= 4.6445 x 2= 9.289,  display 9.28 should be 9.29
rounded tax= 0.2555 x 2 = 0.511 display 0.51 ok
total= 9.28 + 0.51 = 9.79  but i want 9.29+0.51=9.80  (4.90 X 2)

there are two methods:
1. Make the sum of the rounded prices
2. Make the rounding of the sum of the prices


thanks a lot!

Offline abantecart

  • Administrator
  • Hero Member
  • *****
  • Posts: 4359
  • Karma: +298/-10
    • View Profile
    • Ideal Open Source Ecommerce Solution
Re: function round tax is wrong
« Reply #9 on: August 06, 2017, 09:42:53 PM »
hi, ok but how to round price sub total to 2 decimal after it is multiplied by qty?


There is an issue with this approach, and that was the way AbanteCart was working few versions back. There was an issue discovered with penny loss in conversion.

Here is an example of the problem:
Numbers before display: 4.6445 x 2= 9.289, 
Numbers at display and rounding: 4.64 x 2 = 9. 29 (0.01 lost in display)

Currently rounding happen on the product price before multiplication:
Numbers before and after display: 4.64 x 2= 9.28   




Please  rate your experience or leave your review
We need your help to build better free open source ecommerce platform for everyone. See how you can help

 

Powered by SMFPacks Social Login Mod