washington state sales tax integration

This forum is where we'll mirror posts that are of value to the community so they may be more easily found.
User avatar
compunerdy
Admiral (ADM)
Admiral (ADM)
Posts: 1283
Joined: Sun Nov 18, 2007 3:55 pm

washington state sales tax integration

Post by compunerdy » Tue Jul 01, 2008 11:05 pm

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.

User avatar
nickc
Captain (CAPT)
Captain (CAPT)
Posts: 276
Joined: Thu Nov 29, 2007 3:48 pm

Re: washington state sales tax integration

Post by nickc » Wed Jul 02, 2008 10:11 am

Hmm. I may wind up doing this. How many is "a few"?

User avatar
calvis
Rear Admiral (RADM)
Rear Admiral (RADM)
Posts: 710
Joined: Tue Jan 27, 2004 3:57 pm
Location: Redmond, WA

Re: Washington state sales tax integration

Post by calvis » Wed Jul 02, 2008 11:31 am

Put me on the list as a potential contributor.
Able Customer Since 1999 Currently Running on GOLD R12 SR1 and PCI Certified.

User avatar
WylieE
Captain (CAPT)
Captain (CAPT)
Posts: 281
Joined: Tue Mar 25, 2008 8:26 am
Location: Puyallup, WA
Contact:

Re: washington state sales tax integration

Post by WylieE » Wed Jul 02, 2008 5:16 pm

We're working on it. Not sure when it will be ready for prime time though.
Eric Wylie
Warmoth Guitar Products, Inc.
http://www.warmoth.com

User avatar
nickc
Captain (CAPT)
Captain (CAPT)
Posts: 276
Joined: Thu Nov 29, 2007 3:48 pm

Re: washington state sales tax integration

Post by nickc » Wed Jul 02, 2008 5:51 pm

Are you implementing using ITaxProvider?

User avatar
WylieE
Captain (CAPT)
Captain (CAPT)
Posts: 281
Joined: Tue Mar 25, 2008 8:26 am
Location: Puyallup, WA
Contact:

Re: washington state sales tax integration

Post by WylieE » Wed Jul 02, 2008 5:56 pm

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.
Eric Wylie
Warmoth Guitar Products, Inc.
http://www.warmoth.com

User avatar
compunerdy
Admiral (ADM)
Admiral (ADM)
Posts: 1283
Joined: Sun Nov 18, 2007 3:55 pm

Re: washington state sales tax integration

Post by compunerdy » Tue Sep 30, 2008 11:39 am

Anybody get this working or a similar solution?

User avatar
BryanWarmoth
Lieutenant, Jr. Grade (LT JG)
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

Post by BryanWarmoth » Tue Sep 30, 2008 12:06 pm

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.
Last edited by BryanWarmoth on Tue Sep 30, 2008 12:11 pm, edited 1 time in total.
Bryan Bingham
Warmoth Guitar Products Inc.
bryan@warmoth.com
http://www.warmoth.com

User avatar
compunerdy
Admiral (ADM)
Admiral (ADM)
Posts: 1283
Joined: Sun Nov 18, 2007 3:55 pm

Re: washington state sales tax integration

Post by compunerdy » Tue Sep 30, 2008 12:11 pm

Are you willing to share the code or sell it?

User avatar
WylieE
Captain (CAPT)
Captain (CAPT)
Posts: 281
Joined: Tue Mar 25, 2008 8:26 am
Location: Puyallup, WA
Contact:

Re: washington state sales tax integration

Post by WylieE » Tue Sep 30, 2008 1:50 pm

compunerdy wrote:Are you willing to share the code or sell it?
Since most of the code came from WA state, I don't think it would be proper to sell.

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.
Eric Wylie
Warmoth Guitar Products, Inc.
http://www.warmoth.com

User avatar
compunerdy
Admiral (ADM)
Admiral (ADM)
Posts: 1283
Joined: Sun Nov 18, 2007 3:55 pm

Re: washington state sales tax integration

Post by compunerdy » Wed Oct 01, 2008 10:35 am

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.

User avatar
BryanWarmoth
Lieutenant, Jr. Grade (LT JG)
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

Post by BryanWarmoth » Wed Oct 01, 2008 3:52 pm

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:

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;
    }
}
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:

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();
    }
The correct tax should be applied. Let me know if you have any questions.
Bryan Bingham
Warmoth Guitar Products Inc.
bryan@warmoth.com
http://www.warmoth.com

User avatar
Shopping Cart Admin
AbleCommerce Admin
AbleCommerce Admin
Posts: 3055
Joined: Mon Dec 01, 2003 8:41 pm
Location: Vancouver, WA
Contact:

Re: washington state sales tax integration

Post by Shopping Cart Admin » Wed Oct 01, 2008 8:09 pm

Hello Bryan,

Looks like this might end up being a good reference post and wiki doc! Thank you for your contribution.
Thanks for your support

Shopping Cart Guru
AbleCommerce.com
Follow us on Facebook

User avatar
compunerdy
Admiral (ADM)
Admiral (ADM)
Posts: 1283
Joined: Sun Nov 18, 2007 3:55 pm

Re: washington state sales tax integration

Post by compunerdy » Wed Oct 01, 2008 9:09 pm

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?

User avatar
BryanWarmoth
Lieutenant, Jr. Grade (LT JG)
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

Post by BryanWarmoth » Thu Oct 02, 2008 9:59 am

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.
Bryan Bingham
Warmoth Guitar Products Inc.
bryan@warmoth.com
http://www.warmoth.com

User avatar
compunerdy
Admiral (ADM)
Admiral (ADM)
Posts: 1283
Joined: Sun Nov 18, 2007 3:55 pm

Re: washington state sales tax integration

Post by compunerdy » Thu Oct 02, 2008 10:34 am

Ok..still a tad confused :oops:

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? :idea:

User avatar
WylieE
Captain (CAPT)
Captain (CAPT)
Posts: 281
Joined: Tue Mar 25, 2008 8:26 am
Location: Puyallup, WA
Contact:

Re: washington state sales tax integration

Post by WylieE » Thu Oct 02, 2008 4:04 pm

compunerdy wrote:Ok..still a tad confused :oops:

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? :idea:
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.
Eric Wylie
Warmoth Guitar Products, Inc.
http://www.warmoth.com

User avatar
BryanWarmoth
Lieutenant, Jr. Grade (LT JG)
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

Post by BryanWarmoth » Thu Oct 02, 2008 5:51 pm

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.
Bryan Bingham
Warmoth Guitar Products Inc.
bryan@warmoth.com
http://www.warmoth.com

User avatar
compunerdy
Admiral (ADM)
Admiral (ADM)
Posts: 1283
Joined: Sun Nov 18, 2007 3:55 pm

Re: washington state sales tax integration

Post by compunerdy » Thu Oct 02, 2008 11:50 pm

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!!!

User avatar
calvis
Rear Admiral (RADM)
Rear Admiral (RADM)
Posts: 710
Joined: Tue Jan 27, 2004 3:57 pm
Location: Redmond, WA

Re: washington state sales tax integration

Post by calvis » Fri Oct 03, 2008 12:49 am

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.
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.

User avatar
Shopping Cart Admin
AbleCommerce Admin
AbleCommerce Admin
Posts: 3055
Joined: Mon Dec 01, 2003 8:41 pm
Location: Vancouver, WA
Contact:

Re: washington state sales tax integration

Post by Shopping Cart Admin » Fri Oct 03, 2008 12:58 am

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!
Thanks for your support

Shopping Cart Guru
AbleCommerce.com
Follow us on Facebook

User avatar
compunerdy
Admiral (ADM)
Admiral (ADM)
Posts: 1283
Joined: Sun Nov 18, 2007 3:55 pm

Re: washington state sales tax integration

Post by compunerdy » Sat Jan 31, 2009 2:42 pm

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.

User avatar
WylieE
Captain (CAPT)
Captain (CAPT)
Posts: 281
Joined: Tue Mar 25, 2008 8:26 am
Location: Puyallup, WA
Contact:

Re: washington state sales tax integration

Post by WylieE » Mon Feb 02, 2009 10:06 am

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.
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.
Eric Wylie
Warmoth Guitar Products, Inc.
http://www.warmoth.com

User avatar
compunerdy
Admiral (ADM)
Admiral (ADM)
Posts: 1283
Joined: Sun Nov 18, 2007 3:55 pm

Re: washington state sales tax integration

Post by compunerdy » Mon Feb 02, 2009 11:44 am

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.

User avatar
WylieE
Captain (CAPT)
Captain (CAPT)
Posts: 281
Joined: Tue Mar 25, 2008 8:26 am
Location: Puyallup, WA
Contact:

Re: washington state sales tax integration

Post by WylieE » Mon Feb 02, 2009 11:56 am

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.
Uh... you didn't capture that information when you looked up the tax rates ??? :shock: 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)

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!
Eric Wylie
Warmoth Guitar Products, Inc.
http://www.warmoth.com

Post Reply