Open instinct-ray opened 10 years ago
Proper calculation for USA sales should be : TOTAL = Subtotal - discount + shipping * Tax
+1 for me: Tax should be calculated on the subtotal - discount, as instinct-ray and todd1 say. I've received a complaint about this.
Is this already being looked at for 4.0, or should I try to push it through?
Also, are there other regions of the world where the tax should be calculated on the pre-discount price?
Sure, definitely worth taking another look at. This is where we calculate total prices and this is where we calculate total tax
You'll see in both of those areas that we have made some recent changes, which may have resolved the issues. Take a look, if you like, @jbeales, as I don't think anyone else is heading up the charge here.
Thanks!
Sounds good, thanks for the pointers to the right places in the code.
This change would be a breaking change. Should we have a setting, or at least a filter, to allow people to keep the old behaviour?
On Mon, Jan 26, 2015 at 4:30 PM, Justin Sainton notifications@github.com wrote:
Sure, definitely worth taking another look at. This is where we calculate total prices https://github.com/wp-e-commerce/WP-e-Commerce/blob/master/wpsc-includes/cart.class.php#L823 and this is where we calculate total tax https://github.com/wp-e-commerce/WP-e-Commerce/blob/1b45c7ba40234b9e34b1c9db673e35ce1b23518d/wpsc-taxes/controllers/taxes_controller.class.php#L90-L102
You'll see in both of those areas that we have made some recent changes, which may have resolved the issues. Take a look, if you like, @jbeales https://github.com/jbeales, as I don't think anyone else is heading up the charge here.
Thanks!
— Reply to this email directly or view it on GitHub https://github.com/wp-e-commerce/WP-e-Commerce/issues/1541#issuecomment-71542208 .
Can we elaborate on what exactly would be breaking?
The way tax is calculated when there's a coupon present, for tax exclusive pricing, would change from, (pseudo-code):
$tax = $subtotal * $taxrate;
$total = ($subtotal - $coupons) + $tax + $shipping;
to:
$subtotal = $subtotal - $coupons + $shipping;
$tax = $subtotal * $taxrate;
$total = $subtotal + $tax;
So anyone who relies on the calculation behaving as it does today will have a store that doesn't calculate tax the way they, (and perhaps their tax laws), expect it to.
Just tested something today. Tax to country set to 24%, price 50. If using a coupon that has 100% discount (free checkout) customer still has to pay the tax 12$. Not sure if coupon should apply to tax or not
At the moment it's set to not, and I don't think there's a way to change it. In real life it seems to depend - sometimes the before-discount price is taxed, (like we currently do), and sometimes the discounted price is taxed, (like I want to do).
On Tue, Jan 27, 2015 at 6:24 PM, Joldis Mihai Alexandru < notifications@github.com> wrote:
Just tested something today. Tax to country set to 24%, price 50. If using a coupon that has 100% discount (free checkout) customer still has to pay the tax 12$. Not sure if coupon should apply to tax or not
— Reply to this email directly or view it on GitHub https://github.com/wp-e-commerce/WP-e-Commerce/issues/1541#issuecomment-71750466 .
Looking at the UK rules, this would seem like you would tax the discounted price, not the original price. https://www.gov.uk/vat-businesses/discounts-and-free-gifts
I'm not sure how these rules vary country-to-country
I think that's a sane default, @benhuson.
Hey @JustinSainton -
Any word on the 4.x release date?
The taxing calculation that @jbeales mentioned back on January 26th, has started to become a big issue for our client and we were hoping there'd be a little more chatter about a potential release date.
Thanks!
@drewBlueEarth This is on my to-do list to fix, but I haven't done it yet. I'm hoping I'll get it done before 4.0, or if I don't someone else will. My client has avoided this since January simply by not offering any coupons, but that's not a viable long-term solution.
@drewBlueEarth Sorry to hear that this is a pain point for you as well. I'll bump up the priority on the ticket for 4.0 to do everything we can to make sure it gets in.
Ultimately, we need to make sure that if we're changing the way things work, we provide a very clear way for people to revert the behavior. That's important, which @jbeales has noted. And second, the ticket needs someone to own it, and it sounds like @jbeales is up for it, which is awesome. The big feature for 4.0 is the new theme engine, which I am hard at work on. I imagine we'll have a beta for 4.0 out within the next 3 weeks or so. Depending on how that goes, a release is likely within the next 4-6 weeks.
Hope that is helpful!
I'll own it. My client wants this changed, and if it doesn't happen in 4.0 I'm probably going to have to take advantage of that wpsc_calculate_total_price
filter or something, and fixing the problem is easier.
For a way to revert the behaviour, is a filter enough, or should it be a setting? Do we have a way of knowing how many people actually like the current setup?
@jbeales Knowing how many people depend on it in it's current form would be tricky, but because it's something we haven't heard loads of complaints about, it's hard to say.
That said, I think we're all in agreement, this is the way that makes the most sense.
I think a filter is enough. Let's make sure this is in the beta release and then we can release a blog post on the site clearly communicating the changes and how to revert them. In my mind, reverting the behavior should be as simple as someone adding this to their functions.php file: add_filter( 'wpsc_calculate_tax_on_discounts', '__return_true' )
.
Thoughts on that?
That's exactly what I was expecting to do.
@jbeales That's because you're awesome.
@jbeales yeah... that definitely won't work for our client either (not offering coupons / discounts). Thanks guys, I appreciate the traction on this.
@jbeales any traction here?
Notes on GST (Canada's national sales tax): http://www.cra-arc.gc.ca/E/pub/gp/rc4022/rc4022-e.html#P1462_133649
This is turning into a bigger animal than expected. I'll push changes to this branch in my fork until it's ready for reintegration here.
Edited to change link to the correct branch
Any updates on this? In the UK you always apply tax (VAT) after discounted amount. I made some edits to cart.class.php in the plugin (I really need this working before Black Friday so temporary edits to the plugin are necessary).
I have addeded:
$vat = ( $subtotal - $coupons_amount) / (100) * (20);
$total = ( $subtotal - $coupons_amount + $vat );
I don't need shipping. Just - discounts then + 20% tax.
This works exactly as I want, it shows the correct price. However, I had to switch off tax in the store settings, the new $total isn't what's sent to PayPal and the email sent to the customer after purchase doesn't show my new tax (obviously).
I can't see many topics about this, which is odd, because surely every UK shop running WPEC will need this.
Reverted to a quick fix I found, on line 101 taxes_controller.class.php, commented out:
$total_tax -= $coupon_tax;
, so I simply 'un-commented it' out. Works okay now - showing correct tax and carrying it through to PayPal.
I have no idea how it works, but could a toggle be applied to the line in the back end?
Hi @johnfotios - I'm surprised too that there isn't more outcry about this, but for some reason there isn't. I doubt I'll get this fixed before Black Friday, but it looks like you've found the right thing to un-comment to get you through this weekend. When this does get fixed it'll be a bit more robust.
I was certainly expecting more posts about this - hopefully if anyone has the same issue they'll find this topic and be able to sort it as a temporary fix. Great plugin, by the way.
I just read through the Canadian tax document linked above and it looks like there are several kinds of valid coupons in Canadian tax law:
( subtotal - coupon ) * tax_rate
. They are either percentages or dollar amounts.Since both applying the coupon before or after the tax is calculated, and Canadian merchants, (and probably many others), have the option of using both kinds of coupons at the same time, I think the best way to solve this is to add an option to the coupons themselves to specify how that coupon should be applied.
Thoughts?
I think you're right, that we need to have an option here. As I recall, WooCommerce does this. Thoughts on your ability to get this into 4.0? And if that's not possible - do you think that defaulting to the third list item is the way to go for now, and introduce an option down the road?
I'm going to see what I can do tonight. It looks like there's enough remaining before 4.0 goes out that I'll get it in on time.
Could @JustinSainton or @benhuson fill me in on what's going on with the WPSC_Coupon
class vs. the wpsc_coupons
class? There seems to be some duplication going on.
Edit: Nevermind. A closer look at wpsc_coupons
shows me that it uses WPSC_Coupon
for data about the actual coupon.
To-Do list:
WPSC_Coupon
The WPSC_Coupon class is for interacting with a single coupon, methods for getting parameters, validation, saving etc.
The wpsc_coupons class should be for interacting with multiple coupons. E.g. Searching for valid coupons etc
There may be some overlap at the moment, but can be iterate on.
Can someone check my calculations for tax-inclusive jurisdictions? This is what I expect would happen:
A $100 tax-inclusive product, with a 20% tax rate is $83.33 + $16.67 tax. A coupon for $25 off, that is applied before taxes are calculated, would mean the customer would pay $75 - or $62.5 + $12.50 tax, is that correct? (I think it is).
The trickier situation is for coupons that are applied after tax is calculated. In this case, with a $100 and 20% tax, purchase the tax is calculated as $16.67, like above. Then the total price is reduced to $75 by the discount, so we end up with $58.33 + $16.67 = $75, for an effective tax rate of 28.57%, (this number will change based on the size of the coupon). Is there ever a situation where that would happen? Coupons that are applied after the tax is calculated don't seem to make much sense for tax-inclusive pricing.
I have another question, and I'd like as many answers, from as many different tax jurisdictions, as possible:
If a cart looks like this:
$20 item (non-taxable)
$10 item (taxable)
-----------------------------
$30 subtotal
(-$25 coupon)
$5 after-coupon subtotal
Should tax be charged on that remaining $5? My guess would be that yes, it should be taxed, I've got a call in to a Canadian accountant to confirm that's the case in Canada. How about other jurisdictions?
As an aside: In WPeC coupons are applied to the cart as a whole - not to individual items, (although the presence of certain individual items may be needed to use a coupon).
My client just brought this to my attention too - and lucky me, I was able to find this thread.
In this scenario it is doing this:
$99 + 5% tax is $103.95 $99 - 10% discount is $89.10, then it adds the original $4.95 tax = $94.05.
In Canada we would typically charge tax after calculating that subtotal - and in WooCommerce there is an option called apply before tax. I would hesitate a guess that it would cover both likely scenarios:
I find in a lot of cases with clients up here it is only the first scenario: a dollar or percentage discount applied to the cart either through multiples or coupon codes, which has a final amount that tax is then applied to. Most will not have tax inclusive, as we are just used to having a product amount and paying the tax on top of it - unlike the UK where the VAT would be just included in the final price. We also tip in restaurants though, so there is that...
Tested in WPEC 3.8.14.3.
Here's the test case.
Tax is 10% Discount is 10% (from coupon) Item cost is $100
Right now if I were to purchase this item, The sale would be $100.
However, it should work like such. Item cost $100 Item cost after discount : $100 - $10 = $90 Item cost INCLUDING tax = $90 + ( $90 * 10%) = $99
Thank you, Ray