check VAT for local company
I am trying to use http://ec.europa.eu/taxation_customs/vies/vieshome.do?selectedLanguage=EN in c# to check if it's ok
[ClassInterface(ClassInterfaceType.AutoDual)]
[ProgId("DotNetCOM.VerificareCIF")]
public class VerificareCIF
{
public string tara = "RO";
public bool valid = false;
public DateTime data;
public String firma = String.Empty;
public String adresa = String.Empty;
public bool VerifCIF(string CIF)
{
eu.europa.ec.checkVatService service = new eu.europ开发者_JAVA百科a.ec.checkVatService();
data = service.checkVat(ref tara, ref CIF, out valid, out firma, out adresa);
return valid;
}
}
it crashes when i add the web reference
If you don't want to depend on VIES's website, you can use these regular expressions, hashed by the first two letters of the country :
VAT_NUMBER_FORMATS = {
'IE' => /[0-9a-z]{12}/i,
'DK' => /\d{8}/,
'FI' => /\d{8}/,
'LU' => /\d{8}/,
'MT' => /\d{8}/,
'SI' => /\d{8}/,
'HU' => /\d{8}/,
'CZ' => /\d{8,10}/,
'ES' => /[0-9a-z]{9}/i,
'CY' => /\d{8}[a-z]/i,
'DE' => /\d{9}/,
'EL' => /\d{9}/,
'GR' => /\d{9}/,
'PT' => /\d{9}/,
'EE' => /\d{9}/,
'SK' => /\d{8,10}/,
'LT' => /\d{9,12}/,
'GB' => /\d{9}/,
'AT' => /U\d{8}/,
'PL' => /\d{10}/,
'BE' => /\d{10}/,
'LV' => /[0-9a-z]{11}/i,
'IT' => /\d{11}/,
'FR' => /\d{12}/,
'NL' => /[0-9a-z]{12}/i,
'SE' => /\d{12}/,
}
psu - check your output value (out valid) before returning as it could be undefined if there's an error in the service call.
jim
精彩评论