Solved

ColdFusion question - calculating sales tax

Posted on 2006-07-10
3
455 Views
Last Modified: 2013-12-20
I am using Cartweaver shopping cart for ColdFusion.  Cartweaver does not have an option for the below question as far as I can tell, so I'm wondering how i can get this done with custom code.  (I'm *slightly* under pressure!!)
 
The company I work for is in Texas.  I just found out (with 99% of the website done) that we don't charge a flat Texas sales tax.  Normally, if you are in Texas and buy something in Texas, you are charged the flat Texas sales tax.
 
My company bases it's sales tax on the final destination of the product.  We have 5 warehouses in 5 different states.  If an item is being *shipped* to anyone living in one of those 5 states (even if someone out of state purchased it), the purchaser's tax is based on the local rates in that state.
 
Our warehouses are located in New Jersey, Texas, California, Nevada, and Tennessee.  So if someone in Oklahoma buys an item but has it shipped to New Jersey, he/she will be charged the New Jersey tax.  If they live in Oklahoma and the item is shipped to Oklahoma, there is no sales tax.
 
Question 1:  is there a way to code tax based on the shipping address (or zip code maybe?)
Question 2:  California (and I think Nevada) charge city tax instead of state, which means I'd need to enter 100s of different tax percentages for that.  I assume if I can find the code, I can just modify the percentage rate.

Anyone?

Thank you!!!

texastwostep
0
Comment
Question by:texastwostep
  • 2
3 Comments
 
LVL 12

Accepted Solution

by:
mmc98dl1 earned 500 total points
ID: 17078875
1: of course
2: correct

So you could do one of 2 things, store a database table with the zip and percentage next to it, then do a lookup on the table against the database. I would recommend this but dont have time to do a smaple.

Or an array of the same thing.

<cfset zipTax = ArrayNew(2)>
<cfset zipTax[1][1] = 2000><!--- postcode --->
<cfset zipTax[1][2] = 10><!--- percentage --->
<cfset zipTax[2][1] = 2001>
<cfset zipTax[2][2] = 11>
<cfset zipTax[3][1] = 2002>
<cfset zipTax[3][2] = 12>
<cfset zipTax[4][1] = 2003>
<cfset zipTax[4][2] = 13>

<cfset url.userZipCode = 2000>
<cfloop from="0" to="#arrayLen(zipTax)#" index="i">
<cfif zipTax[i][1] eq url.userZipCode>
<cfset taxPercentage = zipTax[i][2]>
</cfif>
</cfloop>

you will have a var called taxPercentage with the correct rate in it.

The theory is the same with a query except you do

<cfquery name="getTaxRates">
Select taxRate, zipCode
FROM taxrates
</cfquery>

<cfloop query="getTaxRates" index="i">
<cfif getTaxRates.zipcode eq url.userZipCode>
<cfset taxPercentage = zipTax.taxRate
</cfif>

HTH
</cfloop>
0
 

Author Comment

by:texastwostep
ID: 17078914
1. i thank you
2. i really, really, really thank you alot!

0
 
LVL 12

Expert Comment

by:mmc98dl1
ID: 17078973
not a problem - glad this helps.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
The purpose of this video is to demonstrate how to make a WordPress Site faster and smaller in size by cleaning up the database. This will be demonstrated using a Windows 8 PC. Plugin WP Optimize will be used. Go to your WordPress login page. T…
The purpose of this video is to demonstrate how to properly insert a Vimeo Video into a WordPress site or Blog. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question