Copied to clipboard

Flag this post as spam?

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


These support forums are now closed for new topics and comments.
Please head on over to http://eureka.ucommerce.net/ for support.

  • Marc Love (uSkinned.net) 447 posts 1789 karma points
    Nov 25, 2013 @ 15:47
    Marc Love (uSkinned.net)
    0

    Apply different VAT rates depending on Shipping Country

    Hi folks, is the subject of this post possible and have any of you out there got experience implementing this?

    Cheers,

    Marc

  • Marc Love (uSkinned.net) 447 posts 1789 karma points
    Nov 27, 2013 @ 16:02
    Marc Love (uSkinned.net)
    0

    Hi again folks, has anyone got any advice in this area?

  • Søren Spelling Lund 1797 posts 2786 karma points
    Nov 27, 2013 @ 17:21
    Søren Spelling Lund
    0

    You can override the ITaxService interface and get the exact behavior you want. It's actually part of the uCommerce Master Class material. Here's the sample we typically develop.

    Once completed register the new class in Custom.config using a component id of "TaxService". You can see how the default calculation is registered in Core.config.

    public class MyTaxService : TaxService
    {
        private readonly IOrderContext _orderContext;
        private readonly IRepository<PriceGroup> _priceGroupRepository;
    
        public MyTaxService(IOrderContext orderContext, IRepository<PriceGroup> priceGroupRepository)
        {
            _orderContext = orderContext;
            _priceGroupRepository = priceGroupRepository;
        }
    
        public override Money CalculateTax(Product product, PriceGroup priceGroup, Money unitPrice)
        {
            var basket = _orderContext.GetBasket();
    
            // If no basket use default calculation
            if (basket == null)
                return base.CalculateTax(product, priceGroup, unitPrice);
    
            // If no shipment use default calculation
            var shipment = basket.PurchaseOrder.Shipments.FirstOrDefault();
            if (shipment == null)
                return base.CalculateTax(product, priceGroup, unitPrice);
    
            // if no shipping address use default calculation
            var shippingAddress = shipment.ShipmentAddress;
            if (shippingAddress == null)
                return base.CalculateTax(product, priceGroup, unitPrice);
    
            // Assume a price group exists with the same name as the country
            var countryPriceGroup = _priceGroupRepository
                .SingleOrDefault(x => x.Name == shippingAddress.Country.Name);
    
            var unitTax = unitPrice.Value*countryPriceGroup.VATRate;
            return new Money(unitTax, priceGroup.Currency);
        }
    }
  • Juhi Paunikar 8 posts 53 karma points
    Feb 25, 2014 @ 09:55
    Juhi Paunikar
    0

    this one is worked for me... Thanks a lot...

Please Sign in or register to post replies

Write your reply to:

Draft