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);
}
}
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
Hi again folks, has anyone got any advice in this area?
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.
this one is worked for me... Thanks a lot...
is working on a reply...