washington state sales tax integration
- compunerdy
- Admiral (ADM)
- Posts: 1283
- Joined: Sun Nov 18, 2007 3:55 pm
washington state sales tax integration
http://dor.wa.gov/Content/FindTaxesAndR ... rface.aspx
Anyone want to tackle making that work?
I know there are a few people on these boards willing to pay for integration for this along with me.
Anyone want to tackle making that work?
I know there are a few people on these boards willing to pay for integration for this along with me.
Re: washington state sales tax integration
Hmm. I may wind up doing this. How many is "a few"?
Nick Cole
http://www.ethofy.com
http://www.ethofy.com
Re: Washington state sales tax integration
Put me on the list as a potential contributor.
Able Customer Since 1999 Currently Running on GOLD R12 SR1 and PCI Certified.
Re: washington state sales tax integration
We're working on it. Not sure when it will be ready for prime time though.
Re: washington state sales tax integration
Are you implementing using ITaxProvider?
Nick Cole
http://www.ethofy.com
http://www.ethofy.com
Re: washington state sales tax integration
No. Homegrown. It's just one of many things we're working on with our new website though. It may not see the light of day for a bit.
Be sure to check out: http://dor.wa.gov/Content/FindTaxesAndR ... brary.aspx
There's quite a bit of information between the two pages listed in this thread.
Be sure to check out: http://dor.wa.gov/Content/FindTaxesAndR ... brary.aspx
There's quite a bit of information between the two pages listed in this thread.
- compunerdy
- Admiral (ADM)
- Posts: 1283
- Joined: Sun Nov 18, 2007 3:55 pm
Re: washington state sales tax integration
Anybody get this working or a similar solution?
- BryanWarmoth
- Lieutenant, Jr. Grade (LT JG)
- Posts: 44
- Joined: Fri May 23, 2008 11:24 am
- Location: Puyallup, Wa
- Contact:
Re: washington state sales tax integration
I created a TaxLookup Class that has methods the use the web services provided by the Department of Revenue of Washington State.
http://dor.wa.gov/Content/FindTaxesAndR ... rface.aspx
They include a c# example that I followed to create the class. The main method of the class takes a basket as a parameter and then grabs the shipping address and applies the correct tax to the order if the customer lives in Washington. It also saves the location code in the shipping fax number field because we don't use if for anything else but I'm sure you could add an extra field if you needed to. The method then returns the basket object back.
NOTE: You have to create a tax code and a tax rule for each of the percentages in washington state. They range from .075 - .090. You then have to set each rule to its corresponding code. Once you get the correct tax rate from WA DOR then find the right tax code and apply it to every item in the basket.
I then added code to the OnePageCheckout ConLib in the RecalculateBasket method to call my tax lookup method. IMPORTANT: Make sure you call basket.Recalculate() after the first big if statement and then add your tax lookup code and then recalculate the basket again so that tax will be applied to the shipping amount as well. You have to repeat this process for the Admin area if you use it to place orders. I put the code inside the UpdateShipMethod() method in PlaceOrder2.aspx.
Hope this helps. Let me know if you need any more help.
http://dor.wa.gov/Content/FindTaxesAndR ... rface.aspx
They include a c# example that I followed to create the class. The main method of the class takes a basket as a parameter and then grabs the shipping address and applies the correct tax to the order if the customer lives in Washington. It also saves the location code in the shipping fax number field because we don't use if for anything else but I'm sure you could add an extra field if you needed to. The method then returns the basket object back.
NOTE: You have to create a tax code and a tax rule for each of the percentages in washington state. They range from .075 - .090. You then have to set each rule to its corresponding code. Once you get the correct tax rate from WA DOR then find the right tax code and apply it to every item in the basket.
I then added code to the OnePageCheckout ConLib in the RecalculateBasket method to call my tax lookup method. IMPORTANT: Make sure you call basket.Recalculate() after the first big if statement and then add your tax lookup code and then recalculate the basket again so that tax will be applied to the shipping amount as well. You have to repeat this process for the Admin area if you use it to place orders. I put the code inside the UpdateShipMethod() method in PlaceOrder2.aspx.
Hope this helps. Let me know if you need any more help.
Last edited by BryanWarmoth on Tue Sep 30, 2008 12:11 pm, edited 1 time in total.
- compunerdy
- Admiral (ADM)
- Posts: 1283
- Joined: Sun Nov 18, 2007 3:55 pm
Re: washington state sales tax integration
Are you willing to share the code or sell it?
Re: washington state sales tax integration
Since most of the code came from WA state, I don't think it would be proper to sell.compunerdy wrote:Are you willing to share the code or sell it?
Seriously, check out the work the DoR has done. It is fairly complete. If it doesn't make sense, let us know where you need help.
- compunerdy
- Admiral (ADM)
- Posts: 1283
- Joined: Sun Nov 18, 2007 3:55 pm
Re: washington state sales tax integration
I am not much of a programmer so if you can share the modified files that would be great. If not then I am still looking for someone willing to turn this into a for sale module or share the files to make it work.
- BryanWarmoth
- Lieutenant, Jr. Grade (LT JG)
- Posts: 44
- Joined: Fri May 23, 2008 11:24 am
- Location: Puyallup, Wa
- Contact:
Re: washington state sales tax integration
Sorry for the wait. Hopefully this will help you out. The code hasn't been tested in a production environment yet but it has been working while we have been testing.
First you need to create a tax code and a corresponding tax rule for every tax rate in washington (0.075-0.090).
Create a new c# class file called TaxLookUp.cs in your App_Code folder and paste this code into it:
Take a close look at the switch statment. I am setting the tax codes based on the rate that WA DOR returns. The numbers I am using are the ids of the tax codes in my database so most likely you will need to change them.
You will then need to call the function to add the correct tax to a customers basket.
Go to ConLib/OnePageCheckout.ascx.cs and replace the recalculateBasket() function with this:
The correct tax should be applied. Let me know if you have any questions.
First you need to create a tax code and a corresponding tax rule for every tax rate in washington (0.075-0.090).
Create a new c# class file called TaxLookUp.cs in your App_Code folder and paste this code into it:
Code: Select all
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using CommerceBuilder.Orders;
using CommerceBuilder.Taxes;
using System.Net;
using System.IO;
using System.Xml;
/// <summary>
/// Summary description for TaxLookUp
/// </summary>
public class TaxLookUp
{
public TaxLookUp()
{
}
public Basket getTaxCodes(Basket basket)
{
BasketShipment shipment = basket.Shipments[0];
XmlDocument doc = new XmlDocument();
string xml = "";
if (shipment.Address.ProvinceId == 93)
{
WebClient wc = new WebClient();
string protocol = "http";
string server = "dor.wa.gov";
string port = "";
string street = shipment.Address.Address1;
string city = shipment.Address.City;
string zip = shipment.Address.PostalCode;
string urlPrefix = protocol +
"://" + server +
"/AddressRates.aspx?output=xml";
string uri = urlPrefix +
"&addr=" +
street +
"&city=" +
city +
"&zip=" +
zip;
StreamReader reader = new StreamReader(wc.OpenRead(uri));
xml = reader.ReadToEnd();
reader.Close();
// Now parse the XML
// ...
//doc = new XmlDocument();
doc.LoadXml(xml);
//doc.Save(Server);
XmlNode node = doc.SelectSingleNode("response");
XmlNode addressNode = doc.SelectSingleNode("addressline");
string locCode = node.Attributes["loccode"].Value;
string rate = node.Attributes["rate"].Value;
shipment.Address.Fax = locCode;
shipment.Address.Save();
//Get the right tax code
//Set the tax code variable equally to the id of the tax code in your database
int taxCode = 0;
switch (rate)
{
case "0.075":
taxCode = 5;
break;
case "0.076":
taxCode = 6;
break;
case "0.077":
taxCode = 7;
break;
case "0.078":
taxCode = 8;
break;
case "0.079":
taxCode = 9;
break;
case "0.080":
taxCode = 10;
break;
case "0.081":
taxCode = 11;
break;
case "0.082":
taxCode = 12;
break;
case "0.083":
taxCode = 13;
break;
case "0.084":
taxCode = 14;
break;
case "0.085":
taxCode = 15;
break;
case "0.086":
taxCode = 16;
break;
case "0.087":
taxCode = 17;
break;
case "0.088":
taxCode = 18;
break;
case "0.089":
taxCode = 19;
break;
case "0.090":
taxCode = 20;
break;
default:
break;
}
foreach (BasketItem item in basket.Items)
{
item.TaxCodeId = taxCode;
}
basket.Shipments[0].ShipMethod.TaxCodeId = taxCode;
basket.Save();
}
//return basket;
return basket;
}
}
You will then need to call the function to add the correct tax to a customers basket.
Go to ConLib/OnePageCheckout.ascx.cs and replace the recalculateBasket() function with this:
Code: Select all
private void RecalculateBasket(bool rebindPaymentForms)
{
Basket basket = Token.Instance.User.Basket;
if (trShowRates.Visible)
{
int shipmentIndex = 0;
foreach (RepeaterItem item in ShipmentList.Items)
{
BasketShipment shipment = basket.Shipments[shipmentIndex];
DropDownList ShipMethodList = (DropDownList)item.FindControl("ShipMethodList");
if (ShipMethodList != null)
{
shipment.ShipMethodId = AlwaysConvert.ToInt(ShipMethodList.SelectedValue);
}
else
{
shipment.ShipMethodId = 0;
}
shipment.Save();
shipmentIndex++;
}
}
basket.Recalculate();
if (rebindPaymentForms) BindPaymentMethodForms();
//Adding washington state taxes to each item in the basket
TaxLookUp taxes = new TaxLookUp();
basket = taxes.getTaxCodes(basket);
//RECALCULATE SHIPPING, TAXES, DISCOUNTS, ETC.
basket.Recalculate();
_CurrentBasketHash = basket.GetContentHash(OrderItemType.Product);
if (rebindPaymentForms) BindPaymentMethodForms();
}
- Shopping Cart Admin
- AbleCommerce Admin
- Posts: 3055
- Joined: Mon Dec 01, 2003 8:41 pm
- Location: Vancouver, WA
- Contact:
Re: washington state sales tax integration
Hello Bryan,
Looks like this might end up being a good reference post and wiki doc! Thank you for your contribution.
Looks like this might end up being a good reference post and wiki doc! Thank you for your contribution.
- compunerdy
- Admiral (ADM)
- Posts: 1283
- Joined: Sun Nov 18, 2007 3:55 pm
Re: washington state sales tax integration
Ok..
So I create a tax code for 7.5%, 7.6%, etc..
Then I create a tax rule for each as well? What do I do for the postal code fields?
So I create a tax code for 7.5%, 7.6%, etc..
Then I create a tax rule for each as well? What do I do for the postal code fields?
- BryanWarmoth
- Lieutenant, Jr. Grade (LT JG)
- Posts: 44
- Joined: Fri May 23, 2008 11:24 am
- Location: Puyallup, Wa
- Contact:
Re: washington state sales tax integration
Yep, you will have to create a tax rule for each of the tax codes. They should have a 1 to 1 relationship so each tax code should have only one tax rule. You do not need to put anything into the postal code field since we do not want able commerce to apply the tax code based on the postal code.
- compunerdy
- Admiral (ADM)
- Posts: 1283
- Joined: Sun Nov 18, 2007 3:55 pm
Re: washington state sales tax integration
Ok..still a tad confused
1. Do I need to worry about assigning items to the tax codes?
2. Does it matter that all the items are already assigned to a different tax code?
Or does the code ignore all of this anyways so just do what you said to do and quit thinking so hard?
1. Do I need to worry about assigning items to the tax codes?
2. Does it matter that all the items are already assigned to a different tax code?
Or does the code ignore all of this anyways so just do what you said to do and quit thinking so hard?
Re: washington state sales tax integration
No tax codes are assigned to individual items. I believe you'll need to remove taxation from the items, otherwise you may end up with duplicate taxes against the order.compunerdy wrote:Ok..still a tad confused
1. Do I need to worry about assigning items to the tax codes?
2. Does it matter that all the items are already assigned to a different tax code?
Or does the code ignore all of this anyways so just do what you said to do and quit thinking so hard?
- BryanWarmoth
- Lieutenant, Jr. Grade (LT JG)
- Posts: 44
- Joined: Fri May 23, 2008 11:24 am
- Location: Puyallup, Wa
- Contact:
Re: washington state sales tax integration
You don't need to worry about adding tax codes to items. I'm not sure if it matter if they already have tax codes applied to them. None of our items have a tax code associated with them. The code replaces the taxcodeid of each item in the basket but I don't know if Able Commerce replaces them later at checkout or not. Let me know if it works with the tax codes already set or not.
- compunerdy
- Admiral (ADM)
- Posts: 1283
- Joined: Sun Nov 18, 2007 3:55 pm
Re: washington state sales tax integration
I did just what you said to do and I did not change any of my previous setup and it looks to be working fine.
THANKS!!!
THANKS!!!
Re: washington state sales tax integration
Hey Tim,
This is great news that you got the code working!!!
It's great that we have so many Washingtonians willing to share code on here. Especially code that deals with the DOR. I went though one audit with those guys and don't wish to do it again.
This is great news that you got the code working!!!
It's great that we have so many Washingtonians willing to share code on here. Especially code that deals with the DOR. I went though one audit with those guys and don't wish to do it again.
Last edited by calvis on Fri Oct 03, 2008 1:06 am, edited 1 time in total.
Able Customer Since 1999 Currently Running on GOLD R12 SR1 and PCI Certified.
- Shopping Cart Admin
- AbleCommerce Admin
- Posts: 3055
- Joined: Mon Dec 01, 2003 8:41 pm
- Location: Vancouver, WA
- Contact:
Re: washington state sales tax integration
Hello,
Mirrored and moved to good reference posts and this should be a good wiki as well. Thanks again for sharing, we really do have a great community!
Mirrored and moved to good reference posts and this should be a good wiki as well. Thanks again for sharing, we really do have a great community!
- compunerdy
- Admiral (ADM)
- Posts: 1283
- Joined: Sun Nov 18, 2007 3:55 pm
Re: washington state sales tax integration
This did collect the correct sales tax amount as far as I can tell. My system was screwed up a bit because of my initial setup. I think I have it setup correctly now though.
When you go to file the state tax's how are you figuring out which countys you sold to? I know how much of each percentage rate I collected but no clue what amount to which county like the tax setup is asking for.
When you go to file the state tax's how are you figuring out which countys you sold to? I know how much of each percentage rate I collected but no clue what amount to which county like the tax setup is asking for.
Re: washington state sales tax integration
There is a form to fill out on the DOR website. (I cannot find it right now) The form has you list the location code along with the total sales and sales tax collected. My understanding is you use the location code for filing and not the county since sales tax can change within the county due to various taxing districts.compunerdy wrote:This did collect the correct sales tax amount as far as I can tell. My system was screwed up a bit because of my initial setup. I think I have it setup correctly now though.
When you go to file the state tax's how are you figuring out which countys you sold to? I know how much of each percentage rate I collected but no clue what amount to which county like the tax setup is asking for.
- compunerdy
- Admiral (ADM)
- Posts: 1283
- Joined: Sun Nov 18, 2007 3:55 pm
Re: washington state sales tax integration
Ok..yes when I went to fill out the form online it asks for the name or location code.. The problem is how do I know which location codes we sold to? As far as I know all I can easily see is what percentage rate we charged yet there will be like 10 location codes with the same percentage rate.
Re: washington state sales tax integration
Uh... you didn't capture that information when you looked up the tax rates ??? We use the sales tax integration routine to capture the location code (we stuff it in the fax number since we do not track shipping fax numbers)compunerdy wrote:Ok..yes when I went to fill out the form online it asks for the name or location code.. The problem is how do I know which location codes we sold to? As far as I know all I can easily see is what percentage rate we charged yet there will be like 10 location codes with the same percentage rate.
Hmmm... If you have a limited number of WA customers, it may not be too painful to manually look up the info this time. Otherwise, yuck and double yuck!