views:

47

answers:

2

Background
I have a program that has implemented the two "classic" taxes for Ontario Canada: 5% GST and 8% PST. At the beginning of July (2010) the province switched to one combined HST tax of 13% for the most part. Effects and changes here but those aren't the main point of this question...

Question
What are best practices and good solutions to accommodate for future changes easily in retail taxes? Tax changes occur often enough. I'm sure there are a many SO users with good experience.

Because my programming is .NET I'll posture that environment for solutions.

A: 

When it's a simple tax rate such as sales tax, you place the rate in a constant (i.e. readonly decimal OntarioGST = 0.05M) and send out an update to your program with a new constant in response to the rate change.

For more complicated taxes, you can apply the strategy pattern and replace the algorithm in response.

Either way, you will need to roll out updates your software. You can't realistically expect your customers to be able to handle something like "you have to enter a new rate in the configuration file if the rate ever changes".

Mark Rushakoff
+2  A: 

I will suggest these two solutions:

  • Define the tax calculation as plugin to the system so that future changes will be localized within the plugin library. Future changes may involve updating the plugin library or changing the config file. This can be useful too for your application to accomodate for variation in the tax calculation in different provinces. You can build a simple plugin code or look at MEF in CodePlex
  • Introduce a tax table where you define the metadata information regarding the tax and calculation fields/formulate. You can take a step further and define a simple domain specific language (like scripts) that then map to your code fields/logics/intepretation to derive the calculated amount. You main system will load the tax table and use it to drive all the tax calculation. Future updates will hopefully involve updating the tax table file.
Fadrian Sudaman