Forums / Currencies & Sales Taxes, VAT, GST, etc. / WA destination based sales tax

WA destination based sales tax

Locked

Views: 3,917

Results 1 to 7 of 7
This thread is locked. New replies are disabled.
18 Jun 2008, 2:07 PM
#2
pinne avatar

pinne

New Zenner

Join Date:
Jun 2008
Posts:
3
Plugin Contributions:
0

Re: WA destination based sales tax

Anyone ?

Is there a practical solution to this without a mod?

It seems like one would have to enter 1000s of zone records to match up the over lapping zip code / counties if it even is possible.

And the online lookup service they provide: http://dor.wa.gov/Content/FindTaxesandRates/SalesAndUseTaxRates/LookUpATaxRate/
does not lend itself to automation. I would have thought that they could have provided a web service or something....

29 Jul 2008, 4:41 PM
#3
jds580s avatar

jds580s

New Zenner

Join Date:
Oct 2007
Posts:
25
Plugin Contributions:
0

Re: WA destination based sales tax

I'm needing a solution too. I have done a bit of work on the problem but perhaps there are other here who could help finalize the solution.

I'm using the WAStateRateParser.inc.php file from:
http://www.destinationtax.com/washington-state-destination-tax-lookup.htm

And I wrote the following code to call the function

<?php
	// $override_tax_rate is used incase there are any problems connecting to or with the results returned from dor.wa.gov.  (value is percent expressed as a decimle 9% = .09)
	$override_tax_rate = ".09";
	
	// when set to true only the debug settings will be used
	$wa_tax_debug_mode = "true";
	
	// ########## DEBUG SETTINGS ##########
	$wa_tax_debug_address = "6500 Linderson way";
	$wa_tax_debug_city = "";
	$wa_tax_debug_zip = "98501"; // 5 or 9 digit is OK
	
	include_once('WAStateRateParser.inc.php');
	
	if($wa_tax_debug_mode) {
		$wa_tax_address = $wa_tax_debug_address;
		$wa_tax_city = $wa_tax_debug_city;
		$wa_tax_zip = $wa_tax_debug_zip;
	} else {
		$wa_tax_address = $wa_tax_debug_address;
		$wa_tax_city = $wa_tax_debug_city;
		$wa_tax_zip = $wa_tax_debug_zip;
	}
	
	$rate_look = new WAXMLParser($wa_tax_address,$wa_tax_city,$wa_tax_zip);
	$rate_look->setSimpleXML();
	$my_lookup = $rate_look->getParsedData();

	$wa_local_tax_rate = floatval($my_lookup['localrate']);
	$wa_state_tax_rate = floatval($my_lookup['staterate']);
	$wa_tax_rate = ($wa_local_tax_rate + $wa_state_tax_rate);
	
	// check for valid tax rates otherwise go with the highest default rate
	$wa_tax_error = 0;
	if ($wa_local_tax_rate < 1 && $wa_local_tax_rate > .01) { } else { $wa_tax_error++; }
	if ($wa_state_tax_rate < 1 && $wa_state_tax_rate > .06) { } else { $wa_tax_error++; }
	if ($wa_tax_error > 0 ) {
		$wa_tax_rate = $override_tax_rate;
	}
	
	// if in debug mode display returned tax rates for the address given	
	if($wa_tax_debug_mode) {
		echo "WA Tax Rate: <strong>$wa_tax_rate</strong><br>Local Tax Rate: $wa_local_tax_rate<br>State Tax Rate: $wa_state_tax_rate<br><br>";
		if ($wa_tax_error > 0 ) { echo "<br>There were errors with the returned tax rates.  Default tax rate of $override_tax_rate was used instead.<br>"; }
		print_r($my_lookup);
	}
	
?>

The problem I have is I'm not familiar enough with where zen-cart stores the address, city, state, zip of the shipping destination, or how to insert the calculated tax rate to override what zen-cart would do on it's own.

I believe it needs to get inserted somewhere in the file: /includes/modules/order_total/custom/ot_tax.php

I'm sure there are people out there much better at this than I, or perhaps someone has already figured out a better solution to this problem.

Any help is much appreciated!

30 Jul 2008, 4:07 AM
#4
sadie avatar

sadie

Zen Follower

Join Date:
Aug 2004
Posts:
252
Plugin Contributions:
0

Re: WA destination based sales tax

It does not seem feasible to do what our state wants us to do. There are too many overlapping areas (counties) with different sales tax rates to ever implement this. I am not even attempting to do this. It looks like Washington is trying to force people to not comply, or stop shipping to their home state.

30 Jul 2008, 4:11 PM
#5
jds580s avatar

jds580s

New Zenner

Join Date:
Oct 2007
Posts:
25
Plugin Contributions:
0

Re: WA destination based sales tax

sadie:

It does not seem feasible to do what our state wants us to do. There are too many overlapping areas (counties) with different sales tax rates to ever implement this. I am not even attempting to do this. It looks like Washington is trying to force people to not comply, or stop shipping to their home state.

I agree it's a very complicated request, especially for the smaller shops who don't employ dedicated programmers. That's why I'm focusing on an automated solution that could simply be dropped in place on the server and fix the problem.

Just wish I understood a bit more about how zen-cart worked.

17 Oct 2008, 9:41 AM
#6
mik avatar

mik

New Zenner

Join Date:
Mar 2008
Posts:
1
Plugin Contributions:
0

Re: WA destination based sales tax

ohmygod. this has been killing me, but i think i have it licked.

first post, so bear with me. i might ramble from sleep deprivation.

i have no idea how to put together a zc mod, but i would be happy to work with someone who does, to get this out there. i have been up working on this since about three this afternoon (now about two a.m.) so i am not exactly ready to post code. please give me a chance to clean it up.

anyhow, what i am doing is this: i took the csv file offered by the state of wa, which breaks down the city/county zones as larger chunks than just going with zip codes. the result is a smaller file. yay. i opened it in a spreadsheet program (openoffice.org) and killed the header row, and all columns but the location code name, the location code, and the tax rate for said location. i then resaved it as a csv file.

i put together an admittedly ham-fisted script to:
a) parse the csv file,
b) create new rows in the zc table 'zones', using the wa location code preceded by a 9 as the zone_id column. for future updates, the script first deletes all rows with a zone_id greater than 1000. so, a new row looks like: ```
9100 223 WA ADAMS COUNTY

c) update the 'geo_zones' table with rows that look like```
1  	WA  	Washington Local Sales Tax For: ADAMS COUNTY  	NULL  	0001-01-01 00:00:00

d) update the 'zones_to_geo_zones' table to look like ```
1 223 9100 1 NULL 0001-01-01 00:00:00

and e) update the 'tax_rates' table to show the appropriate sales tax for each location: ```
1  	100  	1  	1  	9.0000  	Local Sales Tax ADAMS COUNTY  	NULL  	2008-10-17 01:29:04

and to make it all work:

when someone enters their information in the login page, everything below the 'Address Details' is hidden. clicking a continue button that i added makes an ajax call to the state, using the destinationtax.com code referenced above (a lifesaver) if 'WA' (case-insensitive, of course) is entered in the state field. after the destinationtax.com code returns a location name, that name is inserted into the form. i noticed that the actual state does not matter; it is a zone reference that is passed to the zc database. so, as in my example, since 'adams county' has a zone_code of 'WA', that is what shows up onscreen, on ups labels, etc.

so, when the above ajax call returns true, the rest of the form is revealed.

i need sleep. and i just noticed that i need to pass date/time to the db.