in

dashCommerce

An ASP.NET Open Source e-Commerce Application

How do I configure the dashcommerce tax provider to only charge tax in Washington State?

Last post 07-11-2008 12:53 PM by admin. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 07-11-2008 7:24 AM

    How do I configure the dashcommerce tax provider to only charge tax in Washington State?

     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?

  • 07-11-2008 12:53 PM In reply to

    Re: How do I configure the dashcommerce tax provider to only charge tax in Washington State?

    I'm not sure you need to go all the way down to the dashCommerceTaxProvider - seems to me you should be able to short circut this in the TaxService and only ping the dashCommerceTaxService in cases where the state is Washington. Unless you're a belt and suspenders kind of person, in which case you may want to do it in both places. Smile

    --
    Support dashCommerce - Buy Our Stuff!!


    Find a bug? Create a Work Item for a fast response.. Want to help? Create a patch for us! Documentation? Help us write some!
Page 1 of 1 (2 items)