Based on the company select the sales tax and charges

Hi team ,
based on the item selection the tax are apply.
in my case i want wirte a script for compare two tax id that is one for customer and another is for company .
if this both are same the it is in INSTATE otherwise it is in OUTSTATE so for this how to write custom script??help