Solved

ColdFusion question - calculating sales tax

Posted on 2006-07-10
3
446 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
Comment Utility
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
Comment Utility
1. i thank you
2. i really, really, really thank you alot!

0
 
LVL 12

Expert Comment

by:mmc98dl1
Comment Utility
not a problem - glad this helps.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
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 connect a WordPress website to Google Analytics. This will be demonstrated using a Windows 8 PC Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php :…
The purpose of this video is to demonstrate how to integrate Mailchimp with WordPress, by placing a Mailchimp signup form on a WordPress Page or Post. This will be demonstrated using a Windows 8 PC. Mailchimp will be used. Log into your Mailchi…

772 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now