weDevsOfficial/wepos

Tax Calculation Discrepancies with the Inclusive Tax of WooCommerce.

YeasinArafat1998 opened this issue · 3 comments

Issue Description:
The issue described involves a discrepancy in tax calculation when a product is tax-inclusive and the website's settings are configured to display prices inclusive of tax. This can be better understood with a practical example:

Now, let's consider a product priced at $100, with a 10% inclusive tax. This means the base price of the product is actually $90.91, and the tax component is $9.09. Now, imagine the website settings are such that prices are shown inclusive of tax, both in the shop and during cart and checkout.

Suppose we offer a 50% discount on this product. Logically, the discount should apply to the base price of $90.91, halving it to $45.46. The tax should then be 10% of this discounted price, which is $4.55, making the total price $50 (discounted price plus tax). However, the system is incorrectly calculating the tax on the post-discount price of $50, treating it as the base price. So it calculates 10% of $50 as $5 for tax, instead of correctly calculating 10% of $45.45, which would be $4.55.

This error leads to a higher tax amount being displayed and charged than what should be, according to the original tax-inclusive setup. This discrepancy arises because the system fails to account for the tax already included in the pre-discount price when applying the discount.

To Reproduce:
Go to WooCommerce Tax and adjust the configurations for Product inclusive tax, Display prices in the shop, and Display prices during cart and checkout.
Set a tax rate of 10%.
Next, go to POS screens, add a product to the POS, and apply a 50% discount to observe the discrepancy in the configured settings.

Screenshot:
https://prnt.sc/7IclFp2AAOfb

Environment:
wePOS: v1.2.7
WordPress: v6.4.2
WooCommerce: v8.5.1

@nurul-umbhiya vai please have a look on this. @shashwatahalder01 please check if it's really a issue here.

@Mohaiminulislam1989, working on it, and will let you know ASAP.

@Mohaiminulislam1989 bhai, the issue seems valid.