nopCommerce icon indicating copy to clipboard operation
nopCommerce copied to clipboard

Tax Calculation Different Rates Per Line

Open jmawebtech opened this issue 6 years ago • 1 comments

nopCommerce version: 3.8

In some cases, the the tax rate is 6.25% of part of the item. In the attached example, an item is taxable on $1052, instead of $1315. Our software sends 5% of $1315 to calculate the tax correctly.

Steps to reproduce the problem:

  1. Create an order with a tax rate of 6.25% on line 1 and 5% on line 2.
  2. Add a $100 sub total discount

The correct tax is $284.50 and the nopCommerce tax is $284.83. If you remove the sub total discount, the tax equals $290.75 in both places.

data

Please look at this code:

https://github.com/nopSolutions/nopCommerce/blob/b703cd5cce352307b6a068e3992fced8600f3679/src/Libraries/Nop.Services/Orders/OrderTotalCalculationService.cs

public virtual void GetShoppingCartSubTotal(IList<ShoppingCartItem> cart

jmawebtech avatar Jun 08 '18 01:06 jmawebtech

Please could you explain the calculation by showing the working. I've manually calculated it, and it appears that $284.83 is correct. Here’s how I got it : The Sub-total (without discount and tax) is $4915. For the first item, 3600/4915 is 73.2…% For the second item. 1315/4915 is 26.8..% Therefore, the percentage of the discount taken from the first item is $73.2($100 x 73.2%) and the percentage of the discount taken from the second item is $26.8($100 x 26.8%)

Now subtract the discounts from each item which will give you $3526.8($3600 - $73.2) for the first item, and $1288.2($1315 - $26.8) for the second item.

Let’s calculate the Tax for each item. For the first item, we get $220.425($3526.8 x 6.25%), and $64.41($1288.2 x 5%) for the second item.

And now finally, the total tax will be $284.83($220.425 + $64.41), and that matches the Tax calculated by the System. Therefore, the Tax Calculation does not seem to have any errors. Please correct me if I have miscalculated along the way.

Avron108 avatar Dec 21 '21 16:12 Avron108

The subtotal discount is not added as a separate item to the order, so you cannot specify a fixed tax rate for it (like 6.25% in your example), the discount is proportionally applied to all order items, as @Avron108 correctly calculated above, thanks for this. To use a fixed tax rate for a whole subtotal discount, you need to customize the solution.

RomanovM avatar May 11 '23 13:05 RomanovM