Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Checking the EU VAT Number with an German VAT for non German VAT

0.00/5 (No votes)
1 Dec 2014 1  
Easy library for checking VAT Numbers of European Companies. Only usable with an German VAT for non German VAT!!!

Introduction

This library and demo project are only usable for German users with a German VAT!!!

The "Bundeszentralamt für Steuern" has made an interface to check VAT Numbers from other countries. More information can be found here.

The Code

The main method is just a call of the XML RPC API over an HTML link:

        [XmlRpcUrl("https://evatr.bff-online.de/")]
        public interface ISumAndDiff : IXmlRpcProxy
        {
            [XmlRpcMethod("evatrRPC")]
            string testMyClient(string UstId_1, string UstId_2,
            string Firmenname, string Ort, string PLZ, string Strasse, string Druck);
        }

 public int Response(string UstId_1, string UstId_2,
            string Firmenname, string Ort, string PLZ, string Strasse, bool Druck)
        {
            _Message = string.Empty;
            _Erg_Name = string.Empty;
            _Erg_Ort = string.Empty;
            _Erg_PLZ = string.Empty;
            _Erg_Str = string.Empty;
            _Druck = string.Empty;

            int errorCode = 0;

            ISumAndDiff proxy = XmlRpcProxyGen.Create<ISumAndDiff>();

            string ret = proxy.testMyClient(UstId_1, UstId_2, Firmenname, 
            Ort, PLZ, Strasse, Druck ? "ja" : "nein");        

            var xmlDoc = new XmlDocument();
            xmlDoc.LoadXml(ret);

            XmlNodeList elemList = xmlDoc.GetElementsByTagName("string");

            int.TryParse(elemList[3].InnerXml.ToString(), out errorCode);

            DateTime.TryParse(elemList[23].InnerXml.ToString(), out GueltigAb);
            DateTime.TryParse(elemList[25].InnerXml.ToString(), out GueltigBis);

            _Erg_Name =elemList[21].InnerText;
            _Erg_Ort = elemList[17].InnerText;
            _Erg_PLZ = elemList[9].InnerText;
            _Erg_Str = elemList[31].InnerText;
            _Druck = elemList[7].InnerText;

            if (ErrorCodes.Keys.Contains(errorCode))
            {
                _Message = String.Format(ErrorCodes[errorCode], 
                GueltigAb.ToShortDateString(), GueltigBis.ToShortDateString());
            }
            else
            {
                _Message = string.Empty;
            }

            return errorCode;
        }

Using the Code

To use the code, the DLL has to be added to the project.

The only thing needed to check a UID Number is to call the "Code" method. It gives as result the ErrorCode of the API (the code 200 means that the UID is OK) and a message that explains the ErrorCode.

int code = 0;

                UID.Check check = new Check();

                code = check.Response
                (UstId_1, UstId_2, Firmenname, Ort, PLZ, Strasse, chkQualified.Checked);

                lblErg_Fname.Text =check.ParameterMessage(check.Erg_Name);
                lblErg_Ort.Text = check.ParameterMessage(check.Erg_Ort);
                lblErg_PLZ.Text = check.ParameterMessage(check.Erg_PLZ);
                lblErg_Str.Text = check.ParameterMessage(check.Erg_Str);

txtResult.Text = check.Message;

You can find all ErrorCodes here. (01.12.2014)

History

  • 04.12.2014 - Detailed Parameter Results Added
  • 12.12.2014 - Using the "CookComputing.XmlRpc" Library, the Response recognizes all Company Names

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here