weDevsOfficial / wepos

WooCommerce Point of Sale ( POS ) WordPress Plugin
https://wordpress.org/plugins/wepos/
108 stars 71 forks source link

Tax Calculation Discrepancies with the Inclusive Tax of WooCommerce. #145

Closed YeasinArafat1998 closed 3 months ago

YeasinArafat1998 commented 8 months ago

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

Mohaiminulislam1989 commented 8 months ago

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

shashwatahalder01 commented 8 months ago

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

shashwatahalder01 commented 8 months ago

@Mohaiminulislam1989 bhai, the issue seems valid.