Tax is being applied before discount

cbootcboot Member
in Help edited October 2012
We have a payment plan on our store that you can apply a coupon to. The coupon is a percentage discount. While the discount is working fine, the tax is still being applied to the total purchase price (before coupon). How do we make the tax apply after the coupon discount?
Tagged:
Comments
  • fc_adamfc_adam FoxyCart Team
    @cboot,

    Could you let us know the store and coupon you're referring to so we can take a look?
  • fc_adamfc_adam FoxyCart Team
    @cboot {in response to whisper}

    Thanks for that - we'll take a look.
  • cbootcboot Member
    edited November 2012
    @luke and @fc_adam,

    Thanks for pointing me in the right direction. I developed a solution that seems to fix our problem. Just in case it is useful for anyone else, I've posted it below.

    This code checks the cart for a specific product code, then checks to see if one of two possible coupons are also in the cart. If they are, and if there's also a payment plan in the cart (SECOND_PRODUCT_CODE), then the two products are replaced by two new products with the updated full retail price (so that our tax calculation is corrected). This code could be simplified to replace a product if a specific coupon is applied. (Special thanks to Alistair Robinson for his similar code here: http://alistairrobinson.co.uk/foxycart-replacing-a-cart-item/)
    <script type="text/javascript" charset="utf-8">
    jQuery(document).ready(function(){
    	setTimeout(function() {
    		for (var p = 0; p < fc_json.products.length; p++) {
    			var full_product_position;
    			var coupon_position;			
    			if(fc_json.products[p].code == "PRODUCT_CODE")
    			{
    				full_product_position=p;
    				var full_product_id=fc_json.products[p].id;
    				for(var k in fc_json.coupons){
    					if(fc_json.coupons[k].name =="FIRST_COUPON_NAME" || fc_json.coupons[k].name =="SECOND_COUPON_NAME")
    					{
    						coupon_position=k;
    						for (var p2 = 0; p2 < fc_json.products.length; p2++) {
    							if(fc_json.products[p2].code == "SECOND_PRODUCT_CODE")
    								{
    									var payment_plan_id=fc_json.products[p2].id;
    									replace_products(full_product_id,payment_plan_id);
    								}
    						}
    					}
     
    					function replace_products(first_product_id,second_product_id) {
    						var remove_url="https://YOUR_STORE.foxycart.com/cart?output=json&cart=update&1:id=";+first_product_id+"&1:quantity=0&2:id="+second_product_id+"&2:quantity=0&callback=?";
     
    						// Do the remove request, with parameter quantity=0
    						  $.ajax({
    							async: false,
    							type: "GET",
    							url: remove_url,
    							dataType: 'json'
    						  });
     
    						add_items();
     
    					}
     
    					function add_items() {
     
    					         var add_url=get_add_url();
     
    					  //Do the add request
    					  $.ajax({
    					  async: false,
    					  type: "GET",
    					  url: add_url,
    					  dataType: 'json'
    					  });
     
    					  fc_UpdateCart();
    					}
     
    					function get_add_url()
    					{
    						var add_url="SOME CODE HERE TO GENERATE THE ADD URL"
     
    						return add_url;
    					}
     
    				}
     
    			}
    		}
    	}, 1500);
    });
    </script>
    
  • fc_adamfc_adam FoxyCart Team
    @cboot,

    Thanks for posting your solution! That's great!
  • edited April 2013
    I have the same problem, and there is a checkbox on the coupon setup page that *should* cause the discount to be applied BEFORE the tax, so that the correct tax amount is shown on the receipt. However this checkbox seems to always be "on", I've checked it on and off several times but the final Cart/Checkout form still shows tax being applied before the discount, rather than the other way around. Any ideas?

    What's shown in the checkout screen:
    Screen%20Shot%202013-04-09%20at%201.02.38%20PM.png

    What it should show (my jquery-customized version of the cart which also shows tax amount):
    Screen%20Shot%202013-04-09%20at%201.02.27%20PM.png
    (Ideally it should show -5€ as the discount rather than -4.20€, due to tax-inclusive amounts, but this is a separate topic which I have worked around by using pre-tax prices and customizing the cart for now.)

    Coupon setup:
    Screen%20Shot%202013-04-09%20at%201.04.13%20PM.png

    This is kinda urgent cuz the expo starts tomorrow! :)
  • fc_adamfc_adam FoxyCart Team
    @pvaibhav_tobyrich,

    You've set the discount to be a discount of $4.20 - that's why it's discounting by that amount. Were you wanting to discount by a percentage?

    Also - one other thing, on your checkout, is there a reason you're trying to set the state value to "D-"? That's not a valid value, and is breaking your checkout.
  • Hi Adam,


    I want to put a discount of 5€ on the total amount (i.e. price+tax). The product sells for 79.99 incl vat, and we want to offer it for 74.99 incl. vat. If I set the discount to be 5€, and set "Taxable" to yes, I get total 74.99 no problem, but the VAT is still calculated as 19% of 79.99 rather than 19% of 74.99.

    So I set the discount to pre-tax value of 4.20€, and taxable to no so that it is applied to pre-tax price. Then the VAT is added on top to get final discount of 5€. But as you see the discount is still being applied to after-tax price. FYI I just deleted and recreated the coupon with the same settings, to no effect.

    About the state value - replied on the other post because because I guess it was more relevant there.
  • fc_adamfc_adam FoxyCart Team
    @pvaibhav_tobyrich,

    So to confirm, this is what you're wanting:

    Price: 67.22
    Tax: 19%
    Discount: 5

    Tax: 19% of 67.22 = 12.77
    Price + Tax: 67.22 + 12.77 = 79.99
    Less discount: 74.99

    Correct? If that's the case, simply setting your discount to 5, and not being taxable as it currently is should give you that result.
  • Yes that was my initial thought, until I was told by the finance guy that the tax on the receipt is incorrect because we use VAT-inclusive prices (mandated by law), so we have to do something like:

    final sale price = 74.99
    of which VAT 19% = 11.97

    but foxycart calculates VAT = 12.77

    This is a tricky issue (as I've read in older forum posts about tax-inclusive pricing) that I'm trying to work around. I have summarized all calculations in this screenshot below. Kinda tough to keep track of all those numbers flying around :)

    Screen%20Shot%202013-04-09%20at%202.34.47%20PM.png
  • fc_adamfc_adam FoxyCart Team
    @pvaibhav_tobyrich,

    Currently, FoxyCart doesn't support tax inclusive pricing - so approaching it with our standard tax functionality probably won't get you where you want to be. It's definitely something we're aware of, and planning to add support for - but it's not there yet.

    There are a couple work arounds which are detailed on our wiki under tax tips here: http://wiki.foxycart.com/snippets/start
  • I'm already using the workarounds mentioned there to customize our cart before checkout, and am using pre-tax prices everywhere. So far that's OK. The solution for tax-inclusive discounts is also already implemented in FoxyCart, the "taxable" option set to "yes".

    I think the bug is that checking or unchecking this option seems to have no effect!
  • edited April 2013
    Update: I have tried now various values for discount amount and 'taxable' option and found this:

    for integer values of discount, the taxable option works. For discounts with a decimal in them, it has no effect.

    :-/

    And finally one more update: If I change store locale to English - USA, everything works. I think this is a localization issue because with German locale, commas are used for decimals: €2,55 rather than €2.55

    Furthermore, the issue is not dependent on the string that is typed in the "coupon details", but the actual discount amount. i.e. if I type an integer value in "coupon details" but set it to percentage mode resulting in a non-integer discount amount, issue reappears.
  • fc_adamfc_adam FoxyCart Team
    @pvaibhav_tobyrich,
    for integer values of discount, the taxable option works. For discounts with a decimal in them, it has no effect.

    Oh interesting! Nice catch - that definitely sounds like a bug with locales that use a different separator than a decimal. I'll create a ticket for that here and we'll look into that as soon as possible.
  • Great, is there a way I can follow updates on the bug, or is your bug tracker internal? If it is, would be appreciated if you post an update on this thread when it's fixed, thanks!
  • fc_adamfc_adam FoxyCart Team
    @pvaibhav_tobyrich,

    Our bug tracker is internal only - but I've noted this thread on the ticket so we'll bump the thread when anything changes.
  • Hello there, any updates on this bug?
  • fc_adamfc_adam FoxyCart Team
    @pvaibhav_tobyrich,

    I'm so sorry. I had created the ticket, but another team member who had taken a look had asked some questions and I'd completely missed responding to them, so that ticket is still pending. I've just updated the ticket with the information required and have asked the developer to take another look. Again, I'm sincerely sorry for that!
  • Hi, is this bug fixed yet? We want to offer a 15€ discount on our just-launched product, but at the moment there is no way to do this simple task ...
  • lukeluke FoxyCart Team
    @pvaibhav_tobyrich Thank you so much for bumping this thread. We've been busy with quite a few things but were able to push out a fix for this bug in versions 1.0 and 1.1. It should be working correctly now.
  • @luke Thanks. I have tested it on 1.0 and unfortunately the bug still seems to be present. E.g. I make a discount coupon for 20.00€, everything is fine. But if I change it to 19.98€, the tax is again calculated on the full price. Do I have to update to 1.1?
  • lukeluke FoxyCart Team
    @pvaibhav_tobyrich: That's unfortunate. I had a use case where the bug was reproducible and the fix applied solved it. Can you outline for me exactly what settings you're using? What are product delivery settings on the category, what are the tax settings and what are the specific coupon settings? If we can reproduce the problem as you're seeing it, we can work to fix it.
  • Thanks for looking into it. However we are switching to Shopify due to lack of support for tax-inclusive amounts, this bug and other issues.
  • Was there a fix on this issue ? We seem to have the same problem described above.
  • fc_adamfc_adam FoxyCart Team
    @Lucian,

    I actually just replied to your email you sent into support about this too - if you could reply to that with any more information as to the specific issue you're experiencing - we'll do our best to help!
  • Hie sorry for the late reply basically we need to have a VAT inclusive Price type setup which we can apply non taxable discounts... We are supplying a bunch of countries any suggestions or solutions you have developed to cater for this.
  • fc_adamfc_adam FoxyCart Team
    @Lucian,

    Just so we can see your specific set up - would it be possible for you to reply to the email you sent in with a link to a product and details of a coupon we could add to your cart to replicate? Then also details of what the tax should be. I believe we're on the same page - but seeing your exact set up is the best way to ensure it.
Sign In or Register to comment.