IsValid = VAT.ValidateGBVatNumber("GB 815382335") // False IsValid = VAT.ValidateGBVatNumber("815382334") // True IsValid = VAT.ValidateGBVatNumber("GB815382334") // True Return (checkSum = vatNumber & checkSum = vatNumber) Įxample usage: isValid = VAT.ValidateGBVatNumber("GB 815382334") // True String checkSum = (runningTotal * -1).ToString("00") It is advisable to retain proof of validation. The validity of the VAT numbers of clients and suppliers can be verified on this database. Convert to a string that will have two digits even if the number only has one The tax identification number (intracommunity VAT number) of companies in the member States of the European Union are collected in a computer database which can be consulted at the official EU website, Europa. Subtract 97 until negative - this could perhaps be better done with the modulus operator RunningTotal += currentDigitValue * multipliersByIndex Rtn = Regex.IsMatch(theVATNumber, (startChar + ("((d įor (int i = 0 i wrong character supplied Check that the string matches the requirements Update: public static bool isValidVATNumber(string theVATNumber) I have found vat checkers online but I don't understand how they are working, so I was hoping some one could give some simple answers to the above problem with good explanations? This is for me an exercise in algorithm's. I want to write a C# application that takes a UK VAT Number as input, calculates the checksum using the above formula, and indicates if the number is valid or invalid. The total of the above calculation is 64 + 7 + 30 + 15 + 32 + 6 + 6 = 160ĭeduct 97 from this until the result is negative, the result is 160 – 97 - 97= -34 which is the same as the last two digits: so the VAT number is valid. So for example, the VAT number for BLABLA is GB 815382334 the calculation is: 8 x 8 = 64
The negative sum should be equal to the last 2 digits of the VAT number. Then add up all the sums you have and deduct 97 from the sum until the answer is negative. To validate a UK VAT number manually you can perform the following exercise:Įxcluding the first 2 letters, list the numbers vertically and multiply each by a value starting with 8 and ending with 2. If a VAT number is invalid a business cannot re-claim the VAT. VAT numbers are not randomly or sequentially generated but are based on a formula that can be checked to see if the number is valid.