Validate Vat number in C#
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. If a VAT number
is invalid a business cannot re-claim the VAT.
To validate a UK VAT number manually you can perform the following exercise:
Excluding the first 2 letters, list the numbers vertically and multiply
each by a value starting with 8 and ending with 2. Then add up all the
sums you have and deduct 97 from the sum until the answer is negative. The
negative sum should be equal to the last 2 digits of the VAT number.
So for example, the VAT number for BLABLA is GB 815382334 the calculation is:
8 x 8 = 64
1 x 7 = 7
5 x 6 = 30
3 x 5 = 15
8 x 4 = 32
2 x 3 = 6
3 x 2 = 6
The total of the above calculation is 64 + 7 + 30 + 15 + 32 + 6 + 6 = 160
Deduct 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.
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.
This is for me an exercise in algorithm's. 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?
No comments:
Post a Comment