Tax Calculation "Bug"

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
Hace 14 años
I don't know if this is intentional or not but as a test I added items totalling $3.97 and assigned a 5% tax. The floating point value of the tax is $0.1985 but $0.19 is displayed. Should this round up or does the tax regulation state that it should round down?
Addendum: I just put 2 of an item in my cart. The item is $2.00 and the sub-total for that item is $4.01!?! Either way, the tax at 6% is $0.23, when 6% of $4.01 is $0.2406!
Where can I fix this bug?
Hace 14 años
You'll need look in the source code under Nop.Common/Tax/TaxManager.cs


Maybe this line - 244:

taxTotal = itemsTaxTotal + shippingTax + paymentMethodAdditionalFeeTax;
taxTotal = Math.Round(taxTotal, 2);
return taxTotal;
Hace 14 años
I couldn't find that code in that document. Maybe we have different versions. I'm using version 1.20.

I found this on the msdn website:

        Math.Round(3.44, 1); //Returns 3.4.
        Math.Round(3.45, 1); //Returns 3.4.
        Math.Round(3.46, 1); //Returns 3.5.

        Math.Round(4.34, 1); // Returns 4.3
        Math.Round(4.35, 1); // Returns 4.4
        Math.Round(4.36, 1); // Returns 4.4
Hace 14 años
Yeah so its probably not that line.  I'm using version 1.30 but I just changed my rate to 5% and price to $3.97 so its still the same.  I'll track done the line when I have some time and figure it out.
Hace 14 años
These two lines are what calculates Tax. The first one excluding tax and second one including tax.  It then takes the difference between the two to calculate tax.

ie $3.97 - $3.78 = 0.19


Chage the Calculate Price Method in TaxManager.cs from:



      protected static decimal CalculatePrice(decimal price, decimal percent, bool increase)
        {
            decimal result = decimal.Zero;
            if (increase)
            {
                result = price * (1 + percent / 100);
            }
            else
            {
                result = price - (price) / (100 + percent) * percent;
            }
            return result;
        }



to:

     protected static decimal CalculatePrice(decimal price, decimal percent, bool increase)
        {
            decimal result = decimal.Zero;
            if (increase)
            {
                result = price * (1 + percent / 100);
            }
            else
            {
                result = price - Math.Round(price * (percent / 100), 2);
            }
            return result;
        }


I've tested and seems to work fine, however I'm no Math guru so use at your own risk.

Thanks,
Matthew
Hace 14 años
Thank you very much!
How do I report this as a bug?
Hace 14 años
http://nopcommerce.codeplex.com/
Hace 14 años
I think I'm having the same problem.  Occasionally the tax is off by $.01, so far I have only found it to be too high.  

I can't seem to find "Nop.Common/Tax/TaxManager.cs" to see if I can fix this.  Can someone point me to where I would find that file in version 1.30.  I don't seem to have a Nop.Common directory, I do have /Administration/Tax/General/ and /Administration/Common/ but there doesn't seem to be a Tax/TaxManager.cs anywhere.

Any help is greatly appreciated,
Douglas
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.