Hi,
I'm assuming I need to edit the "GetTaxRate" function in dashcommercetaxprovider.cs. Basiclly what i want is to have it only charge sales tax for shipping addresses that end up being a washington state address (as per the new washington state online sales tax law which requires sales tax to be charged by destination rather than from where the order was placed).
I am thinking all i need to do is add these lines:
if (order.ShippingAddress.StateOrRegion != "WA")
{
foreach (OrderItem orderItem in order.OrderItemCollection)
orderItem.ItemTax = this.DefaultRate;
return;
}
so then i'd just set the default rate to 0.
And then in context of the GetTaxRate function it would be:
public void GetTaxRate(Order order) {
if (order.ShippingAddress.StateOrRegion != "WA")
{
foreach (OrderItem orderItem in order.OrderItemCollection)
orderItem.ItemTax = this.DefaultRate;
return;
}
TaxRequest taxRequest = new TaxRequest();
dashCommerceTaxSvc.License license = new dashCommerceTaxSvc.License();
license.UserName = this.UserName;
license.Password = this.Password;
license.LicenseKey = this.LicenseKey;
taxRequest.License = license;
string countryCode = (order.ShippingAddress == null) ? order.BillingAddress.Country : order.ShippingAddress.Country;
switch(countryCode) {
case "US":
taxRequest.CountryCode = CountryCode.UnitedStates;
taxRequest.RegionCode = (order.ShippingAddress == null) ? order.BillingAddress.PostalCode : order.ShippingAddress.PostalCode;
break;
case "CA":
taxRequest.CountryCode = CountryCode.Canada;
taxRequest.RegionCode = (order.ShippingAddress == null) ? order.BillingAddress.StateOrRegion : order.ShippingAddress.StateOrRegion;
break;
}
TaxBasic taxBasic = new TaxBasic();
taxBasic.Url = GetEndpont();
TaxResponse taxResponse = taxBasic.GetTaxRate(taxRequest);
ExceptionWS[ exceptionArray = taxResponse.ExceptionCollection;
if(exceptionArray.GetUpperBound(0) == -1) {
foreach(OrderItem orderItem in order.OrderItemCollection) {
if(taxResponse.TotalSalesTax > 0) {
orderItem.ItemTax = (orderItem.PricePaid - orderItem.DiscountAmount) * taxResponse.TotalSalesTax;
}
else {
orderItem.ItemTax = (orderItem.PricePaid - orderItem.DiscountAmount) * this.DefaultRate;
}
}
}
else {
throw new Exception(exceptionArray[0].Message);
}
}
Is this correct and is it the only thing i'd need to change to get the required behavior?