Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Puck Holshuijsen 186 posts 729 karma points
    Apr 03, 2023 @ 08:20
    Puck Holshuijsen
    0

    Wrong Tax calculation

    Hi Matt,

    First of all; congratulations on becoming a part of Umbraco! I read the news today :)

    I am having a weird issue with tax calculations. I have a TaxRate with 0%, which is set to the order. I have a custom OrderLine calculator, which in this case, returns the base.CalculateOrderlineUnitPrice. The taxRate is 0.00% (both in the order, orderlines as well as the taxRate.

     return base.CalculateOrderLineUnitPrice(order, orderLine, currencyId, taxRate);
    

    For some reason the Price model for TotalPrice calculates the TAX. enter image description here

    I am not sure if I am doing something wrong or if there is a bug.

    I am using Umbraco 10.4.0 and Vendr 3.0.9

    Thanks!

    Puck

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Apr 03, 2023 @ 08:29
    Matt Brailsford
    0

    Hey Puck,

    Thank you for your kind words 🙏

    Hmm, that does sound weird. In your order line calculator, was is the taxRate property set to that you are passing down to the base.CalculateOrderLineUnitPrice method?

    And do you have anything else hooked up that could be affecting price calculations?

  • Puck Holshuijsen 186 posts 729 karma points
    Apr 03, 2023 @ 09:08
    Puck Holshuijsen
    0

    Hi Matt,

    yes, the taxrate is set to 0.00%.

    I have a shippingcalculator, in which I just found out that the taxrate passed is 21.00% I am assuming that this is the culprit. But I am not sure how this TaxRate is 21.00% (my default one) and not the set taxrate on the order (the 0.00%)

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Apr 03, 2023 @ 09:13
    Matt Brailsford
    100

    Hi Puck,

    Shipping methods in the back office do have a tax class dropdown against them so maybe your shipping method has the default tax class assigned to it?

  • Puck Holshuijsen 186 posts 729 karma points
    Apr 03, 2023 @ 09:36
    Puck Holshuijsen
    0

    Well, I just fixed it.

    Yes, my shipping has the default tax class assigned to it. I just fixed it this way:

     if(context.Order.TaxRate.Value != taxRate.Value)
            {
                taxRate = context.Order.TaxRate;
            }
    
            return base.CalculateShippingMethodPrice(shippingMethod, currencyId, countryId, regionId, taxRate, context);
    

    So basically, if the taxrate, which is passed in the calculation method, is different from the order. I Set the taxrate to the order taxrate.

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Apr 03, 2023 @ 09:38
    Matt Brailsford
    0

    If that works for you, great stuff 👍

  • Puck Holshuijsen 186 posts 729 karma points
    Apr 06, 2023 @ 12:55
    Puck Holshuijsen
    0

    Hi Matt,

    Still got some issues with this unfortunately. I thought this would fix it, but when using Mollie it is expecting the 21% VAT instead of the 0 euro's I am passing to it.

    I tried adding an extra paymentmethod with taxclass set to 0% but to no avail. I was hoping you could tell me how to set the taxrate/class which is passed on to Mollie.

    Thanks!

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Apr 06, 2023 @ 13:00
    Matt Brailsford
    0

    This is where the shipping rate order line is created for Mollie https://github.com/vendrhub/vendr-payment-provider-mollie/blob/v2/dev/src/Vendr.PaymentProviders.Mollie/MollieOneTimePaymentProvider.cs#L202-L212 and you can see it reads the ShippingInfo.TaxRate which it should be getting from the shipping methods defined tax rate in the back office, or the default tax rate if one isn't defined.

  • Puck Holshuijsen 186 posts 729 karma points
    Apr 06, 2023 @ 13:04
    Puck Holshuijsen
    0

    Ahhh yes, i see it.. There is no way to set the TaxClass for the shippingmethod right? Just like i can with the Order:

    order.SetTaxClass(taxClass);
    

    If that's not possible I will have to add extra shippingmethods :)

  • Puck Holshuijsen 186 posts 729 karma points
    Apr 06, 2023 @ 13:16
    Puck Holshuijsen
    0

    Ah Matt, just figured it out! I missed this overriable method :)

      public override TaxRate CalculateShippingMethodTaxRate(ShippingMethodReadOnly shippingMethod, TaxSource taxSource, TaxRate fallbackTaxRate, ShippingCalculatorContext context)
        {
            shippingMethod.MustNotBeNull("shippingMethod");
            fallbackTaxRate.MustNotBeNull("fallbackTaxRate");
            TaxRate result = fallbackTaxRate;
    
            var taxClass = _taxService.GetTaxClass(shippingMethod.TaxClassId.Value).GetTaxRate(taxSource);
    
            if (shippingMethod.TaxClassId.HasValue && context.Order.TaxRate.Value != taxClass.Value)
            {
                return context.Order.TaxRate;
            }
    
            return base.CalculateShippingMethodTaxRate(shippingMethod, taxSource, fallbackTaxRate, context);
        }
    
  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Apr 06, 2023 @ 13:17
    Matt Brailsford
    100

    Yup, that's it. The calculator can also return the tax rate 👍

Please Sign in or register to post replies

Write your reply to:

Draft