[tryton-debian-vcs] vatnumber branch upstream created. 799748a3c1e1dbfad5672985d32394a89e423f1a

Mathias Behrle tryton-debian-vcs at alioth.debian.org
Wed Nov 27 17:15:20 UTC 2013


The following commit has been merged in the upstream branch:
https://alioth.debian.org/plugins/scmgit/cgi-bin/gitweb.cgi/?p=tryton/vatnumber.git;a=commitdiff;h=799748a3c1e1dbfad5672985d32394a89e423f1a
commit 799748a3c1e1dbfad5672985d32394a89e423f1a
Author: Mathias Behrle <mathiasb at m9s.biz>
Date:   Thu Jun 6 19:41:51 2013 +0200

    Adding upstream version 1.1.

diff --git a/CHANGELOG b/CHANGELOG
index 4ab00db..e24a5fa 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,8 @@
+Version 1.1 - 2013-06-01
+* Add Python 3 support
+* Add Check Argentina VAT number
+* Fix check for negative integer
+
 Version 1.0 - 2011-09-28
 * Fix UK VAT check
 * Fix UK VAT 9755 validation
diff --git a/PKG-INFO b/PKG-INFO
index eecea2d..e1b549f 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
-Metadata-Version: 1.0
+Metadata-Version: 1.1
 Name: vatnumber
-Version: 1.0
+Version: 1.1
 Summary: Python module to validate VAT numbers
 Home-page: http://code.google.com/p/vatnumber/
 Author: B2CK
@@ -37,7 +37,8 @@ Classifier: Development Status :: 5 - Production/Stable
 Classifier: Intended Audience :: Developers
 Classifier: License :: OSI Approved :: GNU General Public License (GPL)
 Classifier: Operating System :: OS Independent
-Classifier: Programming Language :: Python
+Classifier: Programming Language :: Python :: 2
+Classifier: Programming Language :: Python :: 3
 Classifier: Topic :: Office/Business :: Financial :: Accounting
 Classifier: Topic :: Software Development :: Internationalization
 Classifier: Topic :: Software Development :: Libraries :: Python Modules
diff --git a/setup.py b/setup.py
index e726086..e6d57a6 100644
--- a/setup.py
+++ b/setup.py
@@ -3,34 +3,42 @@
 #this repository contains the full copyright notices and license terms.
 
 import os
+import re
 from setuptools import setup, find_packages
-import vatnumber
+
 
 def read(fname):
     return open(os.path.join(os.path.dirname(__file__), fname)).read()
 
+
+def get_version():
+    init = read(os.path.join('vatnumber', '__init__.py'))
+    return re.search("__version__ = '([0-9.]*)'", init).group(1)
+
 setup(name='vatnumber',
-        version=vatnumber.__version__,
-        author='B2CK',
-        author_email='info at b2ck.com',
-        url="http://code.google.com/p/vatnumber/",
-        description="Python module to validate VAT numbers",
-        long_description=read('README'),
-        download_url="http://code.google.com/p/vatnumber/downloads/",
-        packages=find_packages(),
-        classifiers=[
-            'Development Status :: 5 - Production/Stable',
-            'Intended Audience :: Developers',
-            'License :: OSI Approved :: GNU General Public License (GPL)',
-            'Operating System :: OS Independent',
-            'Programming Language :: Python',
-            'Topic :: Office/Business :: Financial :: Accounting',
-            'Topic :: Software Development :: Internationalization',
-            'Topic :: Software Development :: Libraries :: Python Modules',
-            ],
-        license='GPL-3',
-        extras_require={
-            'suds': ['suds'],
+    version=get_version(),
+    author='B2CK',
+    author_email='info at b2ck.com',
+    url="http://code.google.com/p/vatnumber/",
+    description="Python module to validate VAT numbers",
+    long_description=read('README'),
+    download_url="http://code.google.com/p/vatnumber/downloads/",
+    packages=find_packages(),
+    classifiers=[
+        'Development Status :: 5 - Production/Stable',
+        'Intended Audience :: Developers',
+        'License :: OSI Approved :: GNU General Public License (GPL)',
+        'Operating System :: OS Independent',
+        'Programming Language :: Python :: 2',
+        'Programming Language :: Python :: 3',
+        'Topic :: Office/Business :: Financial :: Accounting',
+        'Topic :: Software Development :: Internationalization',
+        'Topic :: Software Development :: Libraries :: Python Modules',
+        ],
+    license='GPL-3',
+    extras_require={
+        'suds': ['suds'],
         },
-        test_suite="vatnumber.tests",
+    test_suite="vatnumber.tests",
+    use_2to3=True,
     )
diff --git a/vatnumber.egg-info/PKG-INFO b/vatnumber.egg-info/PKG-INFO
index eecea2d..e1b549f 100644
--- a/vatnumber.egg-info/PKG-INFO
+++ b/vatnumber.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
-Metadata-Version: 1.0
+Metadata-Version: 1.1
 Name: vatnumber
-Version: 1.0
+Version: 1.1
 Summary: Python module to validate VAT numbers
 Home-page: http://code.google.com/p/vatnumber/
 Author: B2CK
@@ -37,7 +37,8 @@ Classifier: Development Status :: 5 - Production/Stable
 Classifier: Intended Audience :: Developers
 Classifier: License :: OSI Approved :: GNU General Public License (GPL)
 Classifier: Operating System :: OS Independent
-Classifier: Programming Language :: Python
+Classifier: Programming Language :: Python :: 2
+Classifier: Programming Language :: Python :: 3
 Classifier: Topic :: Office/Business :: Financial :: Accounting
 Classifier: Topic :: Software Development :: Internationalization
 Classifier: Topic :: Software Development :: Libraries :: Python Modules
diff --git a/vatnumber/__init__.py b/vatnumber/__init__.py
index a11c2fa..c11053c 100644
--- a/vatnumber/__init__.py
+++ b/vatnumber/__init__.py
@@ -6,18 +6,27 @@ http://sima-pc.com/nif.php
 http://en.wikipedia.org/wiki/Vat_number
 '''
 
-__version__ = '1.0'
-VIES_URL='http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl'
+__version__ = '1.1'
+VIES_URL = 'http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl'
+
+
+def _posint(x):
+    value = int(x)
+    if value < 0:
+        raise ValueError('not a positive integer')
+    return value
+
 
 def countries():
     '''
     Return the list of country's codes that have check function
     '''
     res = [x.replace('check_vat_', '').upper() for x in globals()
-            if x.startswith('check_vat_')]
+        if x.startswith('check_vat_')]
     res.sort()
     return res
 
+
 def mult_add(i, j):
     '''
     Sum each digits of the multiplication of i and j.
@@ -28,6 +37,7 @@ def mult_add(i, j):
         res += int(str(mult)[i])
     return res
 
+
 def mod1110(value):
     '''
     Compute ISO 7064, Mod 11,10
@@ -38,6 +48,7 @@ def mod1110(value):
         t = (2 * ((t + c) % 10 or 10)) % 11
     return (11 - t) % 10
 
+
 def check_vat_at(vat):
     '''
     Check Austria VAT number.
@@ -48,13 +59,13 @@ def check_vat_at(vat):
         return False
     num = vat[1:]
     try:
-        int(num)
+        _posint(num)
     except ValueError:
         return False
     check_sum = int(num[0]) + mult_add(2, int(num[1])) + \
-            int(num[2]) + mult_add(2, int(num[3])) + \
-            int(num[4]) + mult_add(2, int(num[5])) + \
-            int(num[6])
+        int(num[2]) + mult_add(2, int(num[3])) + \
+        int(num[4]) + mult_add(2, int(num[5])) + \
+        int(num[6])
     check = 10 - ((check_sum + 4) % 10)
     if check == 10:
         check = 0
@@ -62,6 +73,7 @@ def check_vat_at(vat):
         return False
     return True
 
+
 def check_vat_al(vat):
     '''
     Check Albania VAT number.
@@ -71,13 +83,32 @@ def check_vat_al(vat):
     if vat[0] not in ('J', 'K'):
         return False
     try:
-        int(vat[1:9])
+        _posint(vat[1:9])
     except ValueError:
         return False
     if ord(vat[9]) < 65 or ord(vat[9]) > 90:
         return False
     return True
 
+
+def check_vat_ar(vat):
+    '''
+    Check Argentina VAT number.
+    '''
+    if len(vat) != 11:
+        return False
+    base = [5, 4, 3, 2, 7, 6, 5, 4, 3, 2]
+    aux = 0
+    for i in xrange(10):
+        aux += int(vat[i]) * base[i]
+    aux = 11 - (aux - (int(aux / 11) * 11))
+    if aux == 11:
+        aux = 0
+    if aux == 10:
+        aux = 9
+    return aux == int(vat[10])
+
+
 def check_vat_be(vat):
     '''
     Check Belgium VAT number.
@@ -87,7 +118,7 @@ def check_vat_be(vat):
     if vat[0] != '0':
         return False
     try:
-        int(vat)
+        _posint(vat)
     except ValueError:
         return False
     if int(vat[-2:]) != \
@@ -95,6 +126,7 @@ def check_vat_be(vat):
         return False
     return True
 
+
 def check_vat_bg(vat):
     '''
     Check Bulgaria VAT number.
@@ -105,15 +137,15 @@ def check_vat_bg(vat):
     if len(vat) != 10:
         return False
     try:
-        int(vat)
+        _posint(vat)
     except ValueError:
         return False
     if int(vat[0]) in (2, 3) and \
             int(vat[1:2]) != 22:
         return False
     check_sum = 4 * int(vat[0]) + 3 * int(vat[1]) + 2 * int(vat[2]) + \
-            7 * int(vat[3]) + 6 * int(vat[4]) + 5 * int(vat[5]) + \
-            4 * int(vat[6]) + 3 * int(vat[7]) + 2 * int(vat[8])
+        7 * int(vat[3]) + 6 * int(vat[4]) + 5 * int(vat[5]) + \
+        4 * int(vat[6]) + 3 * int(vat[7]) + 2 * int(vat[8])
     check = 11 - (check_sum % 11)
     if check == 11:
         check = 0
@@ -123,12 +155,13 @@ def check_vat_bg(vat):
         return False
     return True
 
+
 def check_vat_cl(rut):
     '''
     Check Chile RUT number.
     '''
     try:
-        int(rut[:-1])
+        _posint(rut[:-1])
     except ValueError:
         return False
     sum = 0
@@ -142,6 +175,7 @@ def check_vat_cl(rut):
     else:
         return check == int(rut[-1])
 
+
 def check_vat_co(rut):
     '''
     Check Colombian RUT number.
@@ -149,17 +183,18 @@ def check_vat_co(rut):
     if len(rut) != 10:
         return False
     try:
-        int(rut)
+        _posint(rut)
     except ValueError:
         return False
     nums = [3, 7, 13, 17, 19, 23, 29, 37, 41, 43, 47, 53, 59, 67, 71]
     sum = 0
-    for i in range (len(rut) - 2, -1, -1):
+    for i in range(len(rut) - 2, -1, -1):
         sum += int(rut[i]) * nums[len(rut) - 2 - i]
     if sum % 11 > 1:
-         return int(rut[-1]) == 11 - (sum % 11)
+        return int(rut[-1]) == 11 - (sum % 11)
     else:
-         return int(rut[-1]) == sum % 11
+        return int(rut[-1]) == sum % 11
+
 
 def check_vat_cy(vat):
     '''
@@ -168,7 +203,7 @@ def check_vat_cy(vat):
     if len(vat) != 9:
         return False
     try:
-        int(vat[:8])
+        _posint(vat[:8])
     except ValueError:
         return False
     num0 = int(vat[0])
@@ -204,6 +239,7 @@ def check_vat_cy(vat):
         return False
     return True
 
+
 def check_vat_cz(vat):
     '''
     Check Czech Republic VAT number.
@@ -211,7 +247,7 @@ def check_vat_cz(vat):
     if len(vat) not in (8, 9, 10):
         return False
     try:
-        int(vat)
+        _posint(vat)
     except ValueError:
         return False
 
@@ -219,8 +255,8 @@ def check_vat_cz(vat):
         if int(vat[0]) not in (0, 1, 2, 3, 4, 5, 6, 7, 8):
             return False
         check_sum = 8 * int(vat[0]) + 7 * int(vat[1]) + 6 * int(vat[2]) + \
-                5 * int(vat[3]) + 4 * int(vat[4]) + 3 * int(vat[5]) + \
-                2 * int(vat[6])
+            5 * int(vat[3]) + 4 * int(vat[4]) + 3 * int(vat[5]) + \
+            2 * int(vat[6])
         check = 11 - (check_sum % 11)
         if check == 10:
             check = 0
@@ -230,8 +266,8 @@ def check_vat_cz(vat):
             return False
     elif len(vat) == 9 and int(vat[0]) == 6:
         check_sum = 8 * int(vat[1]) + 7 * int(vat[2]) + 6 * int(vat[3]) + \
-                5 * int(vat[4]) + 4 * int(vat[5]) + 3 * int(vat[6]) + \
-                2 * int(vat[7])
+            5 * int(vat[4]) + 4 * int(vat[5]) + 3 * int(vat[6]) + \
+            2 * int(vat[7])
         check = 9 - ((11 - (check_sum % 11)) % 10)
         if check != int(vat[8]):
             return False
@@ -301,6 +337,7 @@ def check_vat_cz(vat):
             return False
     return True
 
+
 def check_vat_de(vat):
     '''
     Check Germany VAT number.
@@ -308,7 +345,7 @@ def check_vat_de(vat):
     if len(vat) != 9:
         return False
     try:
-        int(vat)
+        _posint(vat)
     except ValueError:
         return False
     if int(vat[0:7]) <= 0:
@@ -323,6 +360,7 @@ def check_vat_de(vat):
         return False
     return True
 
+
 def check_vat_dk(vat):
     '''
     Check Denmark VAT number.
@@ -330,18 +368,19 @@ def check_vat_dk(vat):
     if len(vat) != 8:
         return False
     try:
-        int(vat)
+        _posint(vat)
     except ValueError:
         return False
     if int(vat[0]) <= 0:
         return False
     check_sum = 2 * int(vat[0]) + 7 * int(vat[1]) + 6 * int(vat[2]) + \
-            5 * int(vat[3]) + 4 * int(vat[4]) + 3 * int(vat[5]) + \
-            2 * int(vat[6]) + int(vat[7])
+        5 * int(vat[3]) + 4 * int(vat[4]) + 3 * int(vat[5]) + \
+        2 * int(vat[6]) + int(vat[7])
     if check_sum % 11 != 0:
         return False
     return True
 
+
 def check_vat_ee(vat):
     '''
     Check Estonia VAT number.
@@ -349,12 +388,12 @@ def check_vat_ee(vat):
     if len(vat) != 9:
         return False
     try:
-        int(vat)
+        _posint(vat)
     except ValueError:
         return False
     check_sum = 3 * int(vat[0]) + 7 * int(vat[1]) + 1 * int(vat[2]) + \
-            3 * int(vat[3]) + 7 * int(vat[4]) + 1 * int(vat[5]) + \
-            3 * int(vat[6]) + 7 * int(vat[7])
+        3 * int(vat[3]) + 7 * int(vat[4]) + 1 * int(vat[5]) + \
+        3 * int(vat[6]) + 7 * int(vat[7])
     check = 10 - (check_sum % 10)
     if check == 10:
         check = 0
@@ -362,6 +401,7 @@ def check_vat_ee(vat):
         return False
     return True
 
+
 def check_vat_es(vat):
     '''
     Check Spain VAT number.
@@ -397,13 +437,13 @@ def check_vat_es(vat):
 
     if vat[0] in ('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'U', 'V'):
         try:
-            int(vat[1:])
+            _posint(vat[1:])
         except ValueError:
             return False
         check_sum = mult_add(2, int(vat[1])) + int(vat[2]) + \
-                mult_add(2, int(vat[3])) + int(vat[4]) + \
-                mult_add(2, int(vat[5])) + int(vat[6]) + \
-                mult_add(2, int(vat[7]))
+            mult_add(2, int(vat[3])) + int(vat[4]) + \
+            mult_add(2, int(vat[5])) + int(vat[6]) + \
+            mult_add(2, int(vat[7]))
         check = 10 - (check_sum % 10)
         if check == 10:
             check = 0
@@ -412,13 +452,13 @@ def check_vat_es(vat):
         return True
     elif vat[0] in ('N', 'P', 'Q', 'R', 'S', 'W'):
         try:
-            int(vat[1:8])
+            _posint(vat[1:8])
         except ValueError:
             return False
         check_sum = mult_add(2, int(vat[1])) + int(vat[2]) + \
-                mult_add(2, int(vat[3])) + int(vat[4]) + \
-                mult_add(2, int(vat[5])) + int(vat[6]) + \
-                mult_add(2, int(vat[7]))
+            mult_add(2, int(vat[3])) + int(vat[4]) + \
+            mult_add(2, int(vat[5])) + int(vat[6]) + \
+            mult_add(2, int(vat[7]))
         check = 10 - (check_sum % 10)
         check = chr(check + 64)
         if check != vat[8]:
@@ -433,7 +473,7 @@ def check_vat_es(vat):
             check_value = vat[1:8]
 
         try:
-            int(check_value)
+            _posint(check_value)
         except ValueError:
             return False
         check = 1 + (int(check_value) % 23)
@@ -444,7 +484,7 @@ def check_vat_es(vat):
         return True
     else:
         try:
-            int(vat[:8])
+            _posint(vat[:8])
         except ValueError:
             return False
         check = 1 + (int(vat[:8]) % 23)
@@ -454,6 +494,7 @@ def check_vat_es(vat):
             return False
         return True
 
+
 def check_vat_fi(vat):
     '''
     Check Finland VAT number.
@@ -461,12 +502,12 @@ def check_vat_fi(vat):
     if len(vat) != 8:
         return False
     try:
-        int(vat)
+        _posint(vat)
     except ValueError:
         return False
     check_sum = 7 * int(vat[0]) + 9 * int(vat[1]) + 10 * int(vat[2]) + \
-            5 * int(vat[3]) + 8 * int(vat[4]) + 4 * int(vat[5]) + \
-            2 * int(vat[6])
+        5 * int(vat[3]) + 8 * int(vat[4]) + 4 * int(vat[5]) + \
+        2 * int(vat[6])
     check = 11 - (check_sum % 11)
     if check == 11:
         check = 0
@@ -476,6 +517,7 @@ def check_vat_fi(vat):
         return False
     return True
 
+
 def check_vat_fr(vat):
     '''
     Check France VAT number.
@@ -484,13 +526,13 @@ def check_vat_fr(vat):
         return False
 
     try:
-        int(vat[2:11])
+        _posint(vat[2:11])
     except ValueError:
         return False
 
     system = None
     try:
-        int(vat[0:2])
+        _posint(vat[0:2])
         system = 'old'
     except ValueError:
         system = 'new'
@@ -523,6 +565,7 @@ def check_vat_fr(vat):
             return False
         return True
 
+
 def check_vat_gb(vat):
     '''
     Check United Kingdom VAT number.
@@ -530,7 +573,7 @@ def check_vat_gb(vat):
 
     if len(vat) == 5:
         try:
-            int(vat[2:5])
+            _posint(vat[2:5])
         except ValueError:
             return False
 
@@ -546,7 +589,7 @@ def check_vat_gb(vat):
     elif len(vat) == 11 \
             and vat[0:6] in ('GD8888', 'HA8888'):
         try:
-            int(vat[6:11])
+            _posint(vat[6:11])
         except ValueError:
             return False
         if vat[0:2] == 'GD' \
@@ -561,7 +604,7 @@ def check_vat_gb(vat):
     elif len(vat) in (12, 13) \
             and vat[0:3] in ('000', '001'):
         try:
-            int(vat)
+            _posint(vat)
         except ValueError:
             return False
 
@@ -573,14 +616,14 @@ def check_vat_gb(vat):
             return False
 
         check_sum = 8 * int(vat[3]) + 7 * int(vat[4]) + 6 * int(vat[5]) + \
-                5 * int(vat[6]) + 4 * int(vat[7]) + 3 * int(vat[8]) + \
-                2 * int(vat[9]) + 10 * int(vat[10]) + int(vat[11])
+            5 * int(vat[6]) + 4 * int(vat[7]) + 3 * int(vat[8]) + \
+            2 * int(vat[9]) + 10 * int(vat[10]) + int(vat[11])
         if check_sum % 97 != 0:
             return False
         return True
     elif len(vat) in (9, 10, 12):
         try:
-            int(vat)
+            _posint(vat)
         except ValueError:
             return False
 
@@ -592,8 +635,8 @@ def check_vat_gb(vat):
             return False
 
         check_sum = 8 * int(vat[0]) + 7 * int(vat[1]) + 6 * int(vat[2]) + \
-                5 * int(vat[3]) + 4 * int(vat[4]) + 3 * int(vat[5]) + \
-                2 * int(vat[6]) + 10 * int(vat[7]) + int(vat[8])
+            5 * int(vat[3]) + 4 * int(vat[4]) + 3 * int(vat[5]) + \
+            2 * int(vat[6]) + 10 * int(vat[7]) + int(vat[8])
         if int(vat[0:3]) >= 100:
             if check_sum % 97 not in (0, 55, 42):
                 return False
@@ -603,18 +646,19 @@ def check_vat_gb(vat):
         return True
     return False
 
+
 def check_vat_gr(vat):
     '''
     Check Greece VAT number.
     '''
     try:
-        int(vat)
+        _posint(vat)
     except ValueError:
         return False
     if len(vat) == 8:
         check_sum = 128 * int(vat[0]) + 64 * int(vat[1]) + 32 * int(vat[2]) + \
-                16 * int(vat[3]) + 8 * int(vat[4]) + 4 * int(vat[5]) + \
-                2 * int(vat[6])
+            16 * int(vat[3]) + 8 * int(vat[4]) + 4 * int(vat[5]) + \
+            2 * int(vat[6])
         check = check_sum % 11
         if check == 10:
             check = 0
@@ -622,9 +666,9 @@ def check_vat_gr(vat):
             return False
         return True
     elif len(vat) == 9:
-        check_sum = 256 * int(vat[0]) + 128 * int(vat[1]) + 64 * int(vat[2]) + \
-                32 * int(vat[3]) + 16 * int(vat[4]) + 8 * int(vat[5]) + \
-                4 * int(vat[6]) + 2 * int(vat[7])
+        check_sum = 256 * int(vat[0]) + 128 * int(vat[1]) + 64 * int(vat[2]) +\
+            32 * int(vat[3]) + 16 * int(vat[4]) + 8 * int(vat[5]) + \
+            4 * int(vat[6]) + 2 * int(vat[7])
         check = check_sum % 11
         if check == 10:
             check = 0
@@ -633,12 +677,14 @@ def check_vat_gr(vat):
         return True
     return False
 
+
 def check_vat_el(vat):
     '''
     Check Greece VAT number.
     '''
     return check_vat_gr(vat)
 
+
 def check_vat_hr(vat):
     '''
     Check Croatia VAT number.
@@ -646,7 +692,7 @@ def check_vat_hr(vat):
     if len(vat) != 11:
         return False
     try:
-        int(vat)
+        _posint(vat)
     except ValueError:
         return False
     check = mod1110(vat[:-1])
@@ -654,6 +700,7 @@ def check_vat_hr(vat):
         return False
     return True
 
+
 def check_vat_hu(vat):
     '''
     Check Hungary VAT number.
@@ -661,14 +708,14 @@ def check_vat_hu(vat):
     if len(vat) != 8:
         return False
     try:
-        int(vat)
+        _posint(vat)
     except ValueError:
         return False
     if int(vat[0]) <= 0:
         return False
     check_sum = 9 * int(vat[0]) + 7 * int(vat[1]) + 3 * int(vat[2]) + \
-            1 * int(vat[3]) + 9 * int(vat[4]) + 7 * int(vat[5]) + \
-            3 * int(vat[6])
+        1 * int(vat[3]) + 9 * int(vat[4]) + 7 * int(vat[5]) + \
+        3 * int(vat[6])
     check = 10 - (check_sum % 10)
     if check == 10:
         check = 0
@@ -676,6 +723,7 @@ def check_vat_hu(vat):
         return False
     return True
 
+
 def check_vat_ie(vat):
     '''
     Check Ireland VAT number.
@@ -685,8 +733,8 @@ def check_vat_ie(vat):
     if (ord(vat[1]) >= 65 and ord(vat[1]) <= 90) \
             or vat[1] in ('+', '*'):
         try:
-            int(vat[0])
-            int(vat[2:7])
+            _posint(vat[0])
+            _posint(vat[2:7])
         except ValueError:
             return False
 
@@ -694,7 +742,7 @@ def check_vat_ie(vat):
             return False
 
         check_sum = 7 * int(vat[2]) + 6 * int(vat[3]) + 5 * int(vat[4]) + \
-                4 * int(vat[5]) + 3 * int(vat[6]) + 2 * int(vat[0])
+            4 * int(vat[5]) + 3 * int(vat[6]) + 2 * int(vat[0])
         check = check_sum % 23
         if check == 0:
             check = 'W'
@@ -705,13 +753,13 @@ def check_vat_ie(vat):
         return True
     else:
         try:
-            int(vat[0:7])
+            _posint(vat[0:7])
         except ValueError:
             return False
 
         check_sum = 8 * int(vat[0]) + 7 * int(vat[1]) + 6 * int(vat[2]) + \
-                5 * int(vat[3]) + 4 * int(vat[4]) + 3 * int(vat[5]) + \
-                2 * int(vat[6])
+            5 * int(vat[3]) + 4 * int(vat[4]) + 3 * int(vat[5]) + \
+            2 * int(vat[6])
         check = check_sum % 23
         if check == 0:
             check = 'W'
@@ -721,6 +769,7 @@ def check_vat_ie(vat):
             return False
         return True
 
+
 def check_vat_it(vat):
     '''
     Check Italy VAT number.
@@ -728,7 +777,7 @@ def check_vat_it(vat):
     if len(vat) != 11:
         return False
     try:
-        int(vat)
+        _posint(vat)
     except ValueError:
         return False
     if int(vat[0:7]) <= 0:
@@ -738,10 +787,10 @@ def check_vat_it(vat):
         return False
 
     check_sum = int(vat[0]) + mult_add(2, int(vat[1])) + int(vat[2]) + \
-            mult_add(2, int(vat[3])) + int(vat[4]) + \
-            mult_add(2, int(vat[5])) + int(vat[6]) + \
-            mult_add(2, int(vat[7])) + int(vat[8]) + \
-            mult_add(2, int(vat[9]))
+        mult_add(2, int(vat[3])) + int(vat[4]) + \
+        mult_add(2, int(vat[5])) + int(vat[6]) + \
+        mult_add(2, int(vat[7])) + int(vat[8]) + \
+        mult_add(2, int(vat[9]))
     check = 10 - (check_sum % 10)
     if check == 10:
         check = 0
@@ -749,12 +798,13 @@ def check_vat_it(vat):
         return False
     return True
 
+
 def check_vat_lt(vat):
     '''
     Check Lithuania VAT number.
     '''
     try:
-        int(vat)
+        _posint(vat)
     except ValueError:
         return False
 
@@ -762,12 +812,12 @@ def check_vat_lt(vat):
         if int(vat[7]) != 1:
             return False
         check_sum = 1 * int(vat[0]) + 2 * int(vat[1]) + 3 * int(vat[2]) + \
-                4 * int(vat[3]) + 5 * int(vat[4]) + 6 * int(vat[5]) + \
-                7 * int(vat[6]) + 8 * int(vat[7])
+            4 * int(vat[3]) + 5 * int(vat[4]) + 6 * int(vat[5]) + \
+            7 * int(vat[6]) + 8 * int(vat[7])
         if check_sum % 11 == 10:
             check_sum = 3 * int(vat[0]) + 4 * int(vat[1]) + 5 * int(vat[2]) + \
-                    6 * int(vat[3]) + 7 * int(vat[4]) + 8 * int(vat[5]) + \
-                    9 * int(vat[6]) + 1 * int(vat[7])
+                6 * int(vat[3]) + 7 * int(vat[4]) + 8 * int(vat[5]) + \
+                9 * int(vat[6]) + 1 * int(vat[7])
         check = check_sum % 11
         if check == 10:
             check = 0
@@ -778,14 +828,14 @@ def check_vat_lt(vat):
         if int(vat[10]) != 1:
             return False
         check_sum = 1 * int(vat[0]) + 2 * int(vat[1]) + 3 * int(vat[2]) + \
-                4 * int(vat[3]) + 5 * int(vat[4]) + 6 * int(vat[5]) + \
-                7 * int(vat[6]) + 8 * int(vat[7]) + 9 * int(vat[8]) + \
-                1 * int(vat[9]) + 2 * int(vat[10])
+            4 * int(vat[3]) + 5 * int(vat[4]) + 6 * int(vat[5]) + \
+            7 * int(vat[6]) + 8 * int(vat[7]) + 9 * int(vat[8]) + \
+            1 * int(vat[9]) + 2 * int(vat[10])
         if check_sum % 11 == 10:
             check_sum = 3 * int(vat[0]) + 4 * int(vat[1]) + 5 * int(vat[2]) + \
-                    6 * int(vat[3]) + 7 * int(vat[4]) + 8 * int(vat[5]) + \
-                    9 * int(vat[6]) + 1 * int(vat[7]) + 2 * int(vat[8]) + \
-                    3 * int(vat[9]) + 4 * int(vat[10])
+                6 * int(vat[3]) + 7 * int(vat[4]) + 8 * int(vat[5]) + \
+                9 * int(vat[6]) + 1 * int(vat[7]) + 2 * int(vat[8]) + \
+                3 * int(vat[9]) + 4 * int(vat[10])
         check = check_sum % 11
         if check == 10:
             check = 0
@@ -794,6 +844,7 @@ def check_vat_lt(vat):
         return True
     return False
 
+
 def check_vat_lu(vat):
     '''
     Check Luxembourg VAT number.
@@ -801,7 +852,7 @@ def check_vat_lu(vat):
     if len(vat) != 8:
         return False
     try:
-        int(vat)
+        _posint(vat)
     except ValueError:
         return False
     if int(vat[0:6]) <= 0:
@@ -811,6 +862,7 @@ def check_vat_lu(vat):
         return False
     return True
 
+
 def check_vat_lv(vat):
     '''
     Check Latvia VAT number.
@@ -818,14 +870,14 @@ def check_vat_lv(vat):
     if len(vat) != 11:
         return False
     try:
-        int(vat)
+        _posint(vat)
     except ValueError:
         return False
     if int(vat[0]) >= 4:
         check_sum = 9 * int(vat[0]) + 1 * int(vat[1]) + 4 * int(vat[2]) + \
-                8 * int(vat[3]) + 3 * int(vat[4]) + 10 * int(vat[5]) + \
-                2 * int(vat[6]) + 5 * int(vat[7]) + 7 * int(vat[8]) + \
-                6 * int(vat[9])
+            8 * int(vat[3]) + 3 * int(vat[4]) + 10 * int(vat[5]) + \
+            2 * int(vat[6]) + 5 * int(vat[7]) + 7 * int(vat[8]) + \
+            6 * int(vat[9])
         if check_sum % 11 == 4 and int(vat[0]) == 9:
             check_sum = check_sum - 45
         if check_sum % 11 == 4:
@@ -854,6 +906,7 @@ def check_vat_lv(vat):
             return False
         return True
 
+
 def check_vat_mt(vat):
     '''
     Check Malta VAT number.
@@ -861,7 +914,7 @@ def check_vat_mt(vat):
     if len(vat) != 8:
         return False
     try:
-        int(vat)
+        _posint(vat)
     except ValueError:
         return False
 
@@ -869,12 +922,13 @@ def check_vat_mt(vat):
         return False
 
     check_sum = 3 * int(vat[0]) + 4 * int(vat[1]) + 6 * int(vat[2]) + \
-            7 * int(vat[3]) + 8 * int(vat[4]) + 9 * int(vat[5])
+        7 * int(vat[3]) + 8 * int(vat[4]) + 9 * int(vat[5])
     check = 37 - (check_sum % 37)
     if check != int(vat[6:8]):
         return False
     return True
 
+
 def check_vat_nl(vat):
     '''
     Check Netherlands VAT number.
@@ -882,8 +936,8 @@ def check_vat_nl(vat):
     if len(vat) != 12:
         return False
     try:
-        int(vat[0:9])
-        int(vat[10:12])
+        _posint(vat[0:9])
+        _posint(vat[10:12])
     except ValueError:
         return False
     if int(vat[0:8]) <= 0:
@@ -892,8 +946,8 @@ def check_vat_nl(vat):
         return False
 
     check_sum = 9 * int(vat[0]) + 8 * int(vat[1]) + 7 * int(vat[2]) + \
-            6 * int(vat[3]) + 5 * int(vat[4]) + 4 * int(vat[5]) + \
-            3 * int(vat[6]) + 2 * int(vat[7])
+        6 * int(vat[3]) + 5 * int(vat[4]) + 4 * int(vat[5]) + \
+        3 * int(vat[6]) + 2 * int(vat[7])
 
     check = check_sum % 11
     if check == 10:
@@ -902,6 +956,7 @@ def check_vat_nl(vat):
         return False
     return True
 
+
 def check_vat_pl(vat):
     '''
     Check Poland VAT number.
@@ -909,13 +964,13 @@ def check_vat_pl(vat):
     if len(vat) != 10:
         return False
     try:
-        int(vat)
+        _posint(vat)
     except ValueError:
         return False
 
     check_sum = 6 * int(vat[0]) + 5 * int(vat[1]) + 7 * int(vat[2]) + \
-            2 * int(vat[3]) + 3 * int(vat[4]) + 4 * int(vat[5]) + \
-            5 * int(vat[6]) + 6 * int(vat[7]) + 7 * int(vat[8])
+        2 * int(vat[3]) + 3 * int(vat[4]) + 4 * int(vat[5]) + \
+        5 * int(vat[6]) + 6 * int(vat[7]) + 7 * int(vat[8])
     check = check_sum % 11
     if check == 10:
         return False
@@ -923,6 +978,7 @@ def check_vat_pl(vat):
         return False
     return True
 
+
 def check_vat_pt(vat):
     '''
     Check Portugal VAT number.
@@ -930,7 +986,7 @@ def check_vat_pt(vat):
     if len(vat) != 9:
         return False
     try:
-        int(vat)
+        _posint(vat)
     except ValueError:
         return False
 
@@ -938,8 +994,8 @@ def check_vat_pt(vat):
         return False
 
     check_sum = 9 * int(vat[0]) + 8 * int(vat[1]) + 7 * int(vat[2]) + \
-            6 * int(vat[3]) + 5 * int(vat[4]) + 4 * int(vat[5]) + \
-            3 * int(vat[6]) + 2 * int(vat[7])
+        6 * int(vat[3]) + 5 * int(vat[4]) + 4 * int(vat[5]) + \
+        3 * int(vat[6]) + 2 * int(vat[7])
     check = 11 - (check_sum % 11)
     if check == 10 or check == 11:
         check = 0
@@ -947,20 +1003,21 @@ def check_vat_pt(vat):
         return False
     return True
 
+
 def check_vat_ro(vat):
     '''
     Check Romania VAT number.
     '''
     try:
-        int(vat)
+        _posint(vat)
     except ValueError:
         return False
 
     if len(vat) >= 2 and len(vat) <= 10:
         vat = (10 - len(vat)) * '0' + vat
         check_sum = 7 * int(vat[0]) + 5 * int(vat[1]) + 3 * int(vat[2]) + \
-                2 * int(vat[3]) + 1 * int(vat[4]) + 7 * int(vat[5]) + \
-                5 * int(vat[6]) + 3 * int(vat[7]) + 2 * int(vat[8])
+            2 * int(vat[3]) + 1 * int(vat[4]) + 7 * int(vat[5]) + \
+            5 * int(vat[6]) + 3 * int(vat[7]) + 2 * int(vat[8])
         check = (check_sum * 10) % 11
         if check == 10:
             check = 0
@@ -986,9 +1043,9 @@ def check_vat_ro(vat):
                 return False
 
         check_sum = 2 * int(vat[0]) + 7 * int(vat[1]) + 9 * int(vat[2]) + \
-                1 * int(vat[3]) + 4 * int(vat[4]) + 6 * int(vat[5]) + \
-                3 * int(vat[6]) + 5 * int(vat[7]) + 8 * int(vat[8]) + \
-                2 * int(vat[9]) + 7 * int(vat[10]) + 9 * int(vat[11])
+            1 * int(vat[3]) + 4 * int(vat[4]) + 6 * int(vat[5]) + \
+            3 * int(vat[6]) + 5 * int(vat[7]) + 8 * int(vat[8]) + \
+            2 * int(vat[9]) + 7 * int(vat[10]) + 9 * int(vat[11])
         check = check_sum % 11
         if check == 10:
             check = 1
@@ -997,6 +1054,7 @@ def check_vat_ro(vat):
         return True
     return False
 
+
 def check_vat_se(vat):
     '''
     Check Sweden VAT number.
@@ -1004,17 +1062,17 @@ def check_vat_se(vat):
     if len(vat) != 12:
         return False
     try:
-        int(vat)
+        _posint(vat)
     except ValueError:
         return False
     if int(vat[10:12]) <= 0:
         return False
 
     check_sum = mult_add(2, int(vat[0])) + int(vat[1]) + \
-            mult_add(2, int(vat[2])) + int(vat[3]) + \
-            mult_add(2, int(vat[4])) + int(vat[5]) + \
-            mult_add(2, int(vat[6])) + int(vat[7]) + \
-            mult_add(2, int(vat[8]))
+        mult_add(2, int(vat[2])) + int(vat[3]) + \
+        mult_add(2, int(vat[4])) + int(vat[5]) + \
+        mult_add(2, int(vat[6])) + int(vat[7]) + \
+        mult_add(2, int(vat[8]))
     check = 10 - (check_sum % 10)
     if check == 10:
         check = 0
@@ -1022,6 +1080,7 @@ def check_vat_se(vat):
         return False
     return True
 
+
 def check_vat_si(vat):
     '''
     Check Slovenia VAT number.
@@ -1029,15 +1088,15 @@ def check_vat_si(vat):
     if len(vat) != 8:
         return False
     try:
-        int(vat)
+        _posint(vat)
     except ValueError:
         return False
     if int(vat[0:7]) <= 999999:
         return False
 
     check_sum = 8 * int(vat[0]) + 7 * int(vat[1]) + 6 * int(vat[2]) + \
-            5 * int(vat[3]) + 4 * int(vat[4]) + 3 * int(vat[5]) + \
-            2 * int(vat[6])
+        5 * int(vat[3]) + 4 * int(vat[4]) + 3 * int(vat[5]) + \
+        2 * int(vat[6])
     check = 11 - (check_sum % 11)
     if check == 10:
         check = 0
@@ -1047,12 +1106,13 @@ def check_vat_si(vat):
         return False
     return True
 
+
 def check_vat_sk(vat):
     '''
     Check Slovakia VAT number.
     '''
     try:
-        int(vat)
+        _posint(vat)
     except ValueError:
         return False
     if len(vat) not in(9, 10):
@@ -1066,7 +1126,7 @@ def check_vat_sk(vat):
             return False
 
     if len(vat) == 9:
-        if int(vat[0:2]) > 53 :
+        if int(vat[0:2]) > 53:
             return False
 
     if int(vat[2:4]) < 1:
@@ -1090,6 +1150,7 @@ def check_vat_sk(vat):
             return False
     return True
 
+
 def check_vat_sm(vat):
     '''
     Check San Marino VAT number.
@@ -1097,11 +1158,12 @@ def check_vat_sm(vat):
     if len(vat) != 5:
         return False
     try:
-        int(vat)
+        _posint(vat)
     except ValueError:
         return False
     return True
 
+
 def check_vat_ua(vat):
     '''
     Check Ukraine VAT number.
@@ -1109,17 +1171,19 @@ def check_vat_ua(vat):
     if len(vat) != 8:
         return False
     try:
-        int(vat)
+        _posint(vat)
     except ValueError:
         return False
     return True
 
+
 def check_vat_uk(vat):
     '''
     Check United Kingdom VAT number.
     '''
     return check_vat_gb(vat)
 
+
 def check_vat_ru(vat):
     '''
     Check Russia VAT number.
@@ -1127,35 +1191,36 @@ def check_vat_ru(vat):
     if len(vat) != 10 and len(vat) != 12:
         return False
     try:
-        int(vat)
+        _posint(vat)
     except ValueError:
         return False
 
     if len(vat) == 10:
         check_sum = 2 * int(vat[0]) + 4 * int(vat[1]) + 10 * int(vat[2]) + \
-                3 * int(vat[3]) + 5 * int(vat[4]) + 9 * int(vat[5]) + \
-                4 * int(vat[6]) + 6 * int(vat[7]) + 8 * int(vat[8])
+            3 * int(vat[3]) + 5 * int(vat[4]) + 9 * int(vat[5]) + \
+            4 * int(vat[6]) + 6 * int(vat[7]) + 8 * int(vat[8])
         check = check_sum % 11
         if check % 10 != int(vat[9]):
             return False
     else:
         check_sum1 = 7 * int(vat[0]) + 2 * int(vat[1]) + 4 * int(vat[2]) + \
-                10 * int(vat[3]) + 3 * int(vat[4]) + 5 * int(vat[5]) + \
-                9 * int(vat[6]) + 4 * int(vat[7]) + 6 * int(vat[8]) + \
-                8 * int(vat[9])
+            10 * int(vat[3]) + 3 * int(vat[4]) + 5 * int(vat[5]) + \
+            9 * int(vat[6]) + 4 * int(vat[7]) + 6 * int(vat[8]) + \
+            8 * int(vat[9])
         check = check_sum1 % 11
 
         if check != int(vat[10]):
             return False
         check_sum2 = 3 * int(vat[0]) + 7 * int(vat[1]) + 2 * int(vat[2]) + \
-                4 * int(vat[3]) + 10 * int(vat[4]) + 3 * int(vat[5]) + \
-                5 * int(vat[6]) + 9 * int(vat[7]) + 4 * int(vat[8]) + \
-                6 * int(vat[9]) + 8 * int(vat[10])
+            4 * int(vat[3]) + 10 * int(vat[4]) + 3 * int(vat[5]) + \
+            5 * int(vat[6]) + 9 * int(vat[7]) + 4 * int(vat[8]) + \
+            6 * int(vat[9]) + 8 * int(vat[10])
         check = check_sum2 % 11
         if check != int(vat[11]):
             return False
     return True
 
+
 def check_vat(vat):
     '''
     Check VAT number.
@@ -1168,6 +1233,7 @@ def check_vat(vat):
         return False
     return checker(number)
 
+
 def check_vies(vat):
     '''
     Check VAT number for EU member state using the SOAP Service
diff --git a/vatnumber/tests.py b/vatnumber/tests.py
index 0fa5fb8..d05a450 100644
--- a/vatnumber/tests.py
+++ b/vatnumber/tests.py
@@ -19,6 +19,8 @@ VAT_NUMBERS = [
     ('AL', 'AA9999999L', False),
     ('AL', 'KA9999999L', False),
     ('AL', 'K999999991', False),
+    ('AR', '00000000000', True),
+    ('AR', '00000000001', False),
     ('BE', '0123456749', True),
     ('BE', '0897290877', True),
     ('BE', '01234567490', False),
@@ -162,6 +164,7 @@ VAT_NUMBERS = [
     ('RO', '24736200', True),
     ('RO', '1234567897', True),
     ('RO', '1630615123457', True),
+    ('RO', '-7793957', False),
     ('RU', '5505035011', True),
     ('RU', '550501929014', True),
     ('SE', '123456789701', True),
@@ -193,7 +196,7 @@ class VatNumberTest(unittest.TestCase):
         '''
         for code, number, result in VAT_NUMBERS:
             if result:
-                test = self.assert_
+                test = self.assertTrue
             else:
                 test = self.assertFalse
             test(vatnumber.check_vat(code + number), code + number)
commit b1adfd50af1d4d0bf65861e99f6b65998014b3f2
Author: Mathias Behrle <mathiasb at m9s.biz>
Date:   Wed Sep 28 19:20:58 2011 +0200

    Adding upstream version 1.0.

diff --git a/CHANGELOG b/CHANGELOG
index 08fcfd0..4ab00db 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,9 @@
+Version 1.0 - 2011-09-28
+* Fix UK VAT check
+* Fix UK VAT 9755 validation
+* Fix Sweden 2 last numbers validation
+* Add 999 and 888 as valide IT province of residence
+
 Version 0.9 - 2011-03-17
 * Fix VIES URL
 
diff --git a/PKG-INFO b/PKG-INFO
index c73961b..eecea2d 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.0
 Name: vatnumber
-Version: 0.9
+Version: 1.0
 Summary: Python module to validate VAT numbers
 Home-page: http://code.google.com/p/vatnumber/
 Author: B2CK
diff --git a/vatnumber.egg-info/PKG-INFO b/vatnumber.egg-info/PKG-INFO
index c73961b..eecea2d 100644
--- a/vatnumber.egg-info/PKG-INFO
+++ b/vatnumber.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.0
 Name: vatnumber
-Version: 0.9
+Version: 1.0
 Summary: Python module to validate VAT numbers
 Home-page: http://code.google.com/p/vatnumber/
 Author: B2CK
diff --git a/vatnumber/__init__.py b/vatnumber/__init__.py
index 1e84f34..a11c2fa 100644
--- a/vatnumber/__init__.py
+++ b/vatnumber/__init__.py
@@ -6,7 +6,7 @@ http://sima-pc.com/nif.php
 http://en.wikipedia.org/wiki/Vat_number
 '''
 
-__version__ = '0.9'
+__version__ = '1.0'
 VIES_URL='http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl'
 
 def countries():
@@ -567,8 +567,6 @@ def check_vat_gb(vat):
 
         if int(vat[3:10]) < 1:
             return False
-        if int(vat[3:10]) > 19999 and int(vat[3:10]) < 1000000:
-            return False
         if int(vat[10:12]) > 97:
             return False
         if len(vat) == 13 and int(vat[12]) != 3:
@@ -588,8 +586,6 @@ def check_vat_gb(vat):
 
         if int(vat[0:7]) < 1:
             return False
-        if int(vat[0:7]) > 19999 and int(vat[0:7]) < 1000000:
-            return False
         if int(vat[7:9]) > 97:
             return False
         if len(vat) == 10 and int(vat[9]) != 3:
@@ -598,7 +594,7 @@ def check_vat_gb(vat):
         check_sum = 8 * int(vat[0]) + 7 * int(vat[1]) + 6 * int(vat[2]) + \
                 5 * int(vat[3]) + 4 * int(vat[4]) + 3 * int(vat[5]) + \
                 2 * int(vat[6]) + 10 * int(vat[7]) + int(vat[8])
-        if int(vat[0:3]) > 100:
+        if int(vat[0:3]) >= 100:
             if check_sum % 97 not in (0, 55, 42):
                 return False
         else:
@@ -737,11 +733,8 @@ def check_vat_it(vat):
         return False
     if int(vat[0:7]) <= 0:
         return False
-    if int(vat[7:10]) <= 0:
-        return False
-    if int(vat[7:10]) > 100 and int(vat[7:10]) < 120:
-        return False
-    if int(vat[7:10]) > 121:
+    if not((0 <= int(vat[7:10]) <= 100)
+            or int(vat[7:10]) in (120, 121, 888, 999)):
         return False
 
     check_sum = int(vat[0]) + mult_add(2, int(vat[1])) + int(vat[2]) + \
@@ -1014,7 +1007,7 @@ def check_vat_se(vat):
         int(vat)
     except ValueError:
         return False
-    if int(vat[9:11]) <= 0:
+    if int(vat[10:12]) <= 0:
         return False
 
     check_sum = mult_add(2, int(vat[0])) + int(vat[1]) + \
diff --git a/vatnumber/tests.py b/vatnumber/tests.py
index 4ed8438..0fa5fb8 100644
--- a/vatnumber/tests.py
+++ b/vatnumber/tests.py
@@ -134,6 +134,8 @@ VAT_NUMBERS = [
     ('GB', 'HA888856782', True),
     ('GB', '123456782', True),
     ('GB', '102675046', True),
+    ('GB', '100190874', True),
+    ('GB', '003232345', True),
     ('GB', '1234567823', True),
     ('GB', '001123456782', True),
     ('GB', '0011234567823', True),
@@ -147,6 +149,7 @@ VAT_NUMBERS = [
     ('IE', '7A12345J', True),
     ('IE', '1234567T', True),
     ('IT', '12345670017', True),
+    ('IT', '00118439991', True),
     ('LT', '123456715', True),
     ('LT', '123456789011', True),
     ('LU', '12345613', True),
@@ -162,6 +165,7 @@ VAT_NUMBERS = [
     ('RU', '5505035011', True),
     ('RU', '550501929014', True),
     ('SE', '123456789701', True),
+    ('SE', '556728341001', True),
     ('SI', '12345679', True),
     ('SK', '0012345675', True),
     ('SK', '0012345678', True),
commit 940a112397f41689171408d0e254e865851c3a8c
Author: Mathias Behrle <mathiasb at m9s.biz>
Date:   Mon Mar 21 11:43:44 2011 +0100

    Adding upstream version 0.9.

diff --git a/CHANGELOG b/CHANGELOG
index 783d86e..08fcfd0 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,6 @@
+Version 0.9 - 2011-03-17
+* Fix VIES URL
+
 Version 0.8 - 2011-01-18
 * Add GB validation for the "9755" checksum introduced in November 2009
 
diff --git a/PKG-INFO b/PKG-INFO
index 466e5fc..c73961b 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.0
 Name: vatnumber
-Version: 0.8
+Version: 0.9
 Summary: Python module to validate VAT numbers
 Home-page: http://code.google.com/p/vatnumber/
 Author: B2CK
diff --git a/vatnumber.egg-info/PKG-INFO b/vatnumber.egg-info/PKG-INFO
index 466e5fc..c73961b 100644
--- a/vatnumber.egg-info/PKG-INFO
+++ b/vatnumber.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.0
 Name: vatnumber
-Version: 0.8
+Version: 0.9
 Summary: Python module to validate VAT numbers
 Home-page: http://code.google.com/p/vatnumber/
 Author: B2CK
diff --git a/vatnumber/__init__.py b/vatnumber/__init__.py
index 20bc93e..1e84f34 100644
--- a/vatnumber/__init__.py
+++ b/vatnumber/__init__.py
@@ -6,8 +6,8 @@ http://sima-pc.com/nif.php
 http://en.wikipedia.org/wiki/Vat_number
 '''
 
-__version__ = '0.8'
-VIES_URL='http://ec.europa.eu/taxation_customs/vies/services/checkVatService.wsdl'
+__version__ = '0.9'
+VIES_URL='http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl'
 
 def countries():
     '''
commit af9dc75061459e6e525f7fc1cfb25a471788db79
Author: Mathias Behrle <mathiasb at m9s.biz>
Date:   Mon Feb 7 19:49:35 2011 +0100

    Adding upstream version 0.8.

diff --git a/CHANGELOG b/CHANGELOG
index c5ad7d6..783d86e 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,6 @@
+Version 0.8 - 2011-01-18
+* Add GB validation for the "9755" checksum introduced in November 2009
+
 Version 0.7 - 2010-08-24
 * Fix test on last char of Albania
 * Add Check Croatia VAT number
diff --git a/COPYRIGHT b/COPYRIGHT
index 636799b..e55164c 100644
--- a/COPYRIGHT
+++ b/COPYRIGHT
@@ -1,5 +1,5 @@
-Copyright (c) 2008-2010 Cédric Krier.
-Copyright (c) 2008-2010 B2CK.
+Copyright (c) 2008-2011 Cédric Krier.
+Copyright (c) 2008-2011 B2CK.
 
 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
diff --git a/PKG-INFO b/PKG-INFO
index 2900d73..466e5fc 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.0
 Name: vatnumber
-Version: 0.7
+Version: 0.8
 Summary: Python module to validate VAT numbers
 Home-page: http://code.google.com/p/vatnumber/
 Author: B2CK
diff --git a/vatnumber.egg-info/PKG-INFO b/vatnumber.egg-info/PKG-INFO
index 2900d73..466e5fc 100644
--- a/vatnumber.egg-info/PKG-INFO
+++ b/vatnumber.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.0
 Name: vatnumber
-Version: 0.7
+Version: 0.8
 Summary: Python module to validate VAT numbers
 Home-page: http://code.google.com/p/vatnumber/
 Author: B2CK
diff --git a/vatnumber/__init__.py b/vatnumber/__init__.py
index 93cdff0..20bc93e 100644
--- a/vatnumber/__init__.py
+++ b/vatnumber/__init__.py
@@ -6,7 +6,7 @@ http://sima-pc.com/nif.php
 http://en.wikipedia.org/wiki/Vat_number
 '''
 
-__version__ = '0.7'
+__version__ = '0.8'
 VIES_URL='http://ec.europa.eu/taxation_customs/vies/services/checkVatService.wsdl'
 
 def countries():
@@ -598,8 +598,12 @@ def check_vat_gb(vat):
         check_sum = 8 * int(vat[0]) + 7 * int(vat[1]) + 6 * int(vat[2]) + \
                 5 * int(vat[3]) + 4 * int(vat[4]) + 3 * int(vat[5]) + \
                 2 * int(vat[6]) + 10 * int(vat[7]) + int(vat[8])
-        if check_sum % 97 != 0:
-            return False
+        if int(vat[0:3]) > 100:
+            if check_sum % 97 not in (0, 55, 42):
+                return False
+        else:
+            if check_sum % 97 != 0:
+                return False
         return True
     return False
 
@@ -1165,7 +1169,11 @@ def check_vat(vat):
     '''
     code = vat[:2].lower()
     number = vat[2:]
-    return globals()['check_vat_%s' % code](number)
+    try:
+        checker = globals()['check_vat_%s' % code]
+    except KeyError:
+        return False
+    return checker(number)
 
 def check_vies(vat):
     '''
diff --git a/vatnumber/tests.py b/vatnumber/tests.py
index 8864d3f..4ed8438 100644
--- a/vatnumber/tests.py
+++ b/vatnumber/tests.py
@@ -133,6 +133,7 @@ VAT_NUMBERS = [
     ('GB', 'HA567', True),
     ('GB', 'HA888856782', True),
     ('GB', '123456782', True),
+    ('GB', '102675046', True),
     ('GB', '1234567823', True),
     ('GB', '001123456782', True),
     ('GB', '0011234567823', True),
@@ -169,6 +170,7 @@ VAT_NUMBERS = [
     ('SK', '2021853504', True),
     ('SM', '12345', True),
     ('UA', '12345678', True),
+    ('', '12456789', False),
 ]
 
 VIES_NUMBERS = [
commit 1ba35baa45e84d15acfaea532f2a4417a866c956
Author: Mathias Behrle <mathiasb at mbsolutions.selfip.biz>
Date:   Tue Aug 24 21:36:29 2010 +0200

    Adding upstream version 0.7.

diff --git a/CHANGELOG b/CHANGELOG
index 97507d5..c5ad7d6 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,7 @@
+Version 0.7 - 2010-08-24
+* Fix test on last char of Albania
+* Add Check Croatia VAT number
+
 Version 0.6 - 2010-05-30
 * Add generic check_vat method
 * Replace SOAPpy by suds
diff --git a/INSTALL b/INSTALL
index 499bfa0..6037913 100644
--- a/INSTALL
+++ b/INSTALL
@@ -5,7 +5,7 @@ Prerequisites
 -------------
 
  * Python (http://www.python.org/)
- * suds (https://fedorahosted.org/suds/)
+ * Optional: suds (https://fedorahosted.org/suds/)
 
 Installation
 ------------
diff --git a/PKG-INFO b/PKG-INFO
index 76bfeaa..2900d73 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.0
 Name: vatnumber
-Version: 0.6
+Version: 0.7
 Summary: Python module to validate VAT numbers
 Home-page: http://code.google.com/p/vatnumber/
 Author: B2CK
@@ -17,18 +17,18 @@ Description: vatnumber
         
         Here a simple example to validate VAT numbers format::
         
-        >>> import vatnumber
-        >>> vatnumber.check_vat('BE0123456749')
-        True
+            >>> import vatnumber
+            >>> vatnumber.check_vat('BE0123456749')
+            True
         
         Here a simple example to validate European VAT through VIES service::
         
-        >>> import vatnumber
-        >>> vatnumber.check_vies('BE0897290877')
-        True
+            >>> import vatnumber
+            >>> vatnumber.check_vies('BE0897290877')
+            True
         
         
-        For more information please visit the `vatnumber website_`.
+        For more information please visit the `vatnumber website`_.
         
         .. _vatnumber website: http://code.google.com/p/vatnumber/
         
diff --git a/README b/README
index 0696fe0..f6f447c 100644
--- a/README
+++ b/README
@@ -19,6 +19,6 @@ Here a simple example to validate European VAT through VIES service::
     True
 
 
-For more information please visit the `vatnumber website_`.
+For more information please visit the `vatnumber website`_.
 
 .. _vatnumber website: http://code.google.com/p/vatnumber/
diff --git a/vatnumber.egg-info/PKG-INFO b/vatnumber.egg-info/PKG-INFO
index 76bfeaa..2900d73 100644
--- a/vatnumber.egg-info/PKG-INFO
+++ b/vatnumber.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.0
 Name: vatnumber
-Version: 0.6
+Version: 0.7
 Summary: Python module to validate VAT numbers
 Home-page: http://code.google.com/p/vatnumber/
 Author: B2CK
@@ -17,18 +17,18 @@ Description: vatnumber
         
         Here a simple example to validate VAT numbers format::
         
-        >>> import vatnumber
-        >>> vatnumber.check_vat('BE0123456749')
-        True
+            >>> import vatnumber
+            >>> vatnumber.check_vat('BE0123456749')
+            True
         
         Here a simple example to validate European VAT through VIES service::
         
-        >>> import vatnumber
-        >>> vatnumber.check_vies('BE0897290877')
-        True
+            >>> import vatnumber
+            >>> vatnumber.check_vies('BE0897290877')
+            True
         
         
-        For more information please visit the `vatnumber website_`.
+        For more information please visit the `vatnumber website`_.
         
         .. _vatnumber website: http://code.google.com/p/vatnumber/
         
diff --git a/vatnumber/__init__.py b/vatnumber/__init__.py
index c205c16..93cdff0 100644
--- a/vatnumber/__init__.py
+++ b/vatnumber/__init__.py
@@ -6,7 +6,7 @@ http://sima-pc.com/nif.php
 http://en.wikipedia.org/wiki/Vat_number
 '''
 
-__version__ = '0.6'
+__version__ = '0.7'
 VIES_URL='http://ec.europa.eu/taxation_customs/vies/services/checkVatService.wsdl'
 
 def countries():
@@ -28,6 +28,16 @@ def mult_add(i, j):
         res += int(str(mult)[i])
     return res
 
+def mod1110(value):
+    '''
+    Compute ISO 7064, Mod 11,10
+    '''
+    t = 10
+    for i in value:
+        c = int(i)
+        t = (2 * ((t + c) % 10 or 10)) % 11
+    return (11 - t) % 10
+
 def check_vat_at(vat):
     '''
     Check Austria VAT number.
@@ -64,7 +74,7 @@ def check_vat_al(vat):
         int(vat[1:9])
     except ValueError:
         return False
-    if ord(vat[9]) < 65 and ord(vat[9]) > 90:
+    if ord(vat[9]) < 65 or ord(vat[9]) > 90:
         return False
     return True
 
@@ -118,26 +128,25 @@ def check_vat_cl(rut):
     Check Chile RUT number.
     '''
     try:
-        int(str(rut)[:len(str(rut))-1])
+        int(rut[:-1])
     except ValueError:
         return False
     sum = 0
-    RUTLen = len(str(rut))
-    for i in range (RUTLen - 2, -1, -1):
-        sum += int(str(rut)[i]) * (((RUTLen - 2 - i) % 6) + 2)
+    for i in range(len(rut) - 2, -1, -1):
+        sum += int(rut[i]) * (((len(rut) - 2 - i) % 6) + 2)
     check = 11 - (sum % 11)
     if check == 11:
-        return str(rut)[len(str(rut)) -1] == '0'
+        return rut[-1] == '0'
     elif check == 10:
-        return str(rut)[len(str(rut)) -1].upper() == 'K'
+        return rut[-1].upper() == 'K'
     else:
-        return str(check) == str(rut)[len(str(rut)) -1]
+        return check == int(rut[-1])
 
 def check_vat_co(rut):
     '''
     Check Colombian RUT number.
     '''
-    if len(str(rut)) != 10:
+    if len(rut) != 10:
         return False
     try:
         int(rut)
@@ -145,13 +154,12 @@ def check_vat_co(rut):
         return False
     nums = [3, 7, 13, 17, 19, 23, 29, 37, 41, 43, 47, 53, 59, 67, 71]
     sum = 0
-    RUTLen = len(str(rut))
-    for i in range (RUTLen - 2, -1, -1):
-        sum += int(str(rut)[i]) * nums [RUTLen - 2 - i]
+    for i in range (len(rut) - 2, -1, -1):
+        sum += int(rut[i]) * nums[len(rut) - 2 - i]
     if sum % 11 > 1:
-         return str(rut)[RUTLen - 1] == str(11 - (sum % 11))
+         return int(rut[-1]) == 11 - (sum % 11)
     else:
-         return str(rut)[RUTLen - 1] == str(sum % 11)
+         return int(rut[-1]) == sum % 11
 
 def check_vat_cy(vat):
     '''
@@ -288,9 +296,8 @@ def check_vat_cz(vat):
             if int(vat[4:6]) > 31:
                 return False
         if (int(vat[0:2]) + int(vat[2:4]) + int(vat[4:6]) + int(vat[6:8]) +
-                int(vat[8:10])) % 11 != 0:
-            return False
-        if int(vat[0:10]) % 11 != 0:
+                int(vat[8:10])) % 11 != 0 \
+                or int(vat[0:10]) % 11 != 0:
             return False
     return True
 
@@ -632,6 +639,21 @@ def check_vat_el(vat):
     '''
     return check_vat_gr(vat)
 
+def check_vat_hr(vat):
+    '''
+    Check Croatia VAT number.
+    '''
+    if len(vat) != 11:
+        return False
+    try:
+        int(vat)
+    except ValueError:
+        return False
+    check = mod1110(vat[:-1])
+    if check != int(vat[10]):
+        return False
+    return True
+
 def check_vat_hu(vat):
     '''
     Check Hungary VAT number.
@@ -1039,7 +1061,7 @@ def check_vat_sk(vat):
     if len(vat) not in(9, 10):
         return False
 
-    if int(vat[0:2]) == 0 and len(vat) == 10:
+    if int(vat[0:2]) in (0, 10, 20) and len(vat) == 10:
         return True
 
     if len(vat) == 10:
diff --git a/vatnumber/tests.py b/vatnumber/tests.py
index 2152edb..8864d3f 100644
--- a/vatnumber/tests.py
+++ b/vatnumber/tests.py
@@ -8,76 +8,167 @@ import unittest
 import vatnumber
 
 VAT_NUMBERS = [
-    ('AT', 'U12345675'),
-    ('AL', 'K99999999L'),
-    ('BE', '0123456749'),
-    ('BG', '1234567892'),
-    ('BG', '175074752'),
-    ('BG', '131202360'),
-    ('BG', '040683212'),
-    ('CL', '334441113'),
-    ('CO', '9001279338'),
-    ('CY', '12345678F'),
-    ('CZ', '12345679'),
-    ('CZ', '612345670'),
-    ('CZ', '991231123'),
-    ('CZ', '6306150004'),
-    ('DE', '123456788'),
-    ('DK', '12345674'),
-    ('EE', '123456780'),
-    ('ES', 'A12345674'),
-    ('ES', 'P1234567D'),
-    ('ES', 'K1234567L'),
-    ('ES', 'R9600075G'),
-    ('ES', 'W4003922D'),
-    ('ES', 'V99218067'),
-    ('ES', 'U99216632'),
-    ('ES', 'J99216582'),
-    ('ES', 'U99216426'),
-    ('ES', '12345678Z'),
-    ('ES', 'X5277343Q'),
-    ('ES', 'Y5277343F'),
-    ('ES', 'Z5277343K'),
-    ('FI', '12345671'),
-    ('FR', '32123456789'),
-    ('FR', '2H123456789'),
-    ('GB', 'GD123'),
-    ('GB', 'GD888812326'),
-    ('GB', 'HA567'),
-    ('GB', 'HA888856782'),
-    ('GB', '123456782'),
-    ('GB', '1234567823'),
-    ('GB', '001123456782'),
-    ('GB', '0011234567823'),
-    ('GB', '242338087388'),
-    ('GR', '12345670'),
-    ('GR', '123456783'),
-    ('HU', '12345676'),
-    ('IE', '7A12345J'),
-    ('IE', '1234567T'),
-    ('IT', '12345670017'),
-    ('LT', '123456715'),
-    ('LT', '123456789011'),
-    ('LU', '12345613'),
-    ('LV', '41234567891'),
-    ('LV', '15066312345'),
-    ('MT', '12345634'),
-    ('NL', '123456782B90'),
-    ('PL', '1234567883'),
-    ('PT', '123456789'),
-    ('RO', '24736200'),
-    ('RO', '1234567897'),
-    ('RO', '1630615123457'),
-    ('RU', '5505035011'),
-    ('RU', '550501929014'),
-    ('SE', '123456789701'),
-    ('SI', '12345679'),
-    ('SK', '0012345675'),
-    ('SK', '0012345678'),
-    ('SK', '531231123'),
-    ('SK', '6306151234'),
-    ('SM', '12345'),
-    ('UA', '12345678'),
+    ('AT', 'U12345675', True),
+    ('AT', 'U123456789', False),
+    ('AT', 'A12345675', False),
+    ('AT', 'UA2345675', False),
+    ('AT', 'U12345620', True),
+    ('AT', 'U12345678', False),
+    ('AL', 'K99999999L', True),
+    ('AL', 'K999999999L', False),
+    ('AL', 'AA9999999L', False),
+    ('AL', 'KA9999999L', False),
+    ('AL', 'K999999991', False),
+    ('BE', '0123456749', True),
+    ('BE', '0897290877', True),
+    ('BE', '01234567490', False),
+    ('BE', '9123456749', False),
+    ('BE', '0A23456749', False),
+    ('BE', '0123456700', False),
+    ('BG', '1234567892', True),
+    ('BG', '175074752', True),
+    ('BG', '131202360', True),
+    ('BG', '040683212', True),
+    ('BG', '12345678921', False),
+    ('BG', 'A234567892', False),
+    ('BG', '2234567892', False),
+    ('BG', '1001000000', True),
+    ('BG', '0000003000', False),
+    ('BG', '1234567890', False),
+    ('CL', '334441113', True),
+    ('CL', 'A34441113', False),
+    ('CL', '334441180', True),
+    ('CL', '33444113K', True),
+    ('CO', '9001279338', True),
+    ('CO', '900127933', False),
+    ('CO', 'A001279338', False),
+    ('CO', '9001279320', True),
+    ('CY', '12345678F', True),
+    ('CY', '2345678F', False),
+    ('CY', 'A2345678F', False),
+    ('CY', '12345678A', False),
+    ('CZ', '1234567', False),
+    ('CZ', '12345679', True),
+    ('CZ', 'A2345679', False),
+    ('CZ', '92345679', False),
+    ('CZ', '10001000', True),
+    ('CZ', '10000101', True),
+    ('CZ', '12345670', False),
+    ('CZ', '612345670', True),
+    ('CZ', '612345679', False),
+    ('CZ', '991231123', True),
+    ('CZ', '541231123', False),
+    ('CZ', '791231123', False),
+    ('CZ', '990031123', False),
+    ('CZ', '991331123', False),
+    ('CZ', '995031123', False),
+    ('CZ', '996331123', False),
+    ('CZ', '990200123', False),
+    ('CZ', '995229123', False),
+    ('CZ', '965200123', False),
+    ('CZ', '960230123', False),
+    ('CZ', '990400123', False),
+    ('CZ', '990431123', False),
+    ('CZ', '990100123', False),
+    ('CZ', '990132123', False),
+    ('CZ', '6306150004', True),
+    ('CZ', '5306150004', False),
+    ('CZ', '6300150004', False),
+    ('CZ', '6313150004', False),
+    ('CZ', '6350150004', False),
+    ('CZ', '6363150004', False),
+    ('CZ', '6302000004', False),
+    ('CZ', '6302290004', False),
+    ('CZ', '6402000004', False),
+    ('CZ', '6402310004', False),
+    ('CZ', '6304000004', False),
+    ('CZ', '6304310004', False),
+    ('CZ', '6301000004', False),
+    ('CZ', '6301320004', False),
+    ('CZ', '6306150000', False),
+    ('CZ', '6306150004', True),
+    ('DE', '123456788', True),
+    ('DE', '12345678', False),
+    ('DE', 'A23456788', False),
+    ('DE', '000000088', False),
+    ('DE', '123456770', True),
+    ('DE', '123456789', False),
+    ('DK', '12345674', True),
+    ('DK', '1234564', False),
+    ('DK', 'A2345674', False),
+    ('DK', '02345674', False),
+    ('DK', '12345679', False),
+    ('EE', '123456780', True),
+    ('EE', '1234567890', False),
+    ('EE', 'A23456780', False),
+    ('EE', '123456789', False),
+    ('ES', 'A12345674', True),
+    ('ES', 'P1234567D', True),
+    ('ES', 'K1234567L', True),
+    ('ES', 'R9600075G', True),
+    ('ES', 'W4003922D', True),
+    ('ES', 'V99218067', True),
+    ('ES', 'U99216632', True),
+    ('ES', 'J99216582', True),
+    ('ES', 'U99216426', True),
+    ('ES', '12345678Z', True),
+    ('ES', 'X5277343Q', True),
+    ('ES', 'Y5277343F', True),
+    ('ES', 'Z5277343K', True),
+    ('ES', '1234567890', False),
+    ('ES', 'AB3456789', False),
+    ('ES', 'A12345690', True),
+    ('ES', 'A12345679', False),
+    ('ES', 'WA003922D', False),
+    ('ES', 'W4003922A', False),
+    ('ES', 'ZA277343K', False),
+    ('ES', 'Z5277343A', False),
+    ('ES', '1A345678Z', False),
+    ('ES', '12345678A', False),
+    ('FI', '12345671', True),
+    ('FR', '32123456789', True),
+    ('FR', '2H123456789', True),
+    ('GB', 'GD123', True),
+    ('GB', 'GD888812326', True),
+    ('GB', 'HA567', True),
+    ('GB', 'HA888856782', True),
+    ('GB', '123456782', True),
+    ('GB', '1234567823', True),
+    ('GB', '001123456782', True),
+    ('GB', '0011234567823', True),
+    ('GB', '242338087388', True),
+    ('GR', '12345670', True),
+    ('GR', '123456783', True),
+    ('HR', '12345678903', True),
+    ('HR', '24595836665', True),
+    ('HR', '23448731483', True),
+    ('HU', '12345676', True),
+    ('IE', '7A12345J', True),
+    ('IE', '1234567T', True),
+    ('IT', '12345670017', True),
+    ('LT', '123456715', True),
+    ('LT', '123456789011', True),
+    ('LU', '12345613', True),
+    ('LV', '41234567891', True),
+    ('LV', '15066312345', True),
+    ('MT', '12345634', True),
+    ('NL', '123456782B90', True),
+    ('PL', '1234567883', True),
+    ('PT', '123456789', True),
+    ('RO', '24736200', True),
+    ('RO', '1234567897', True),
+    ('RO', '1630615123457', True),
+    ('RU', '5505035011', True),
+    ('RU', '550501929014', True),
+    ('SE', '123456789701', True),
+    ('SI', '12345679', True),
+    ('SK', '0012345675', True),
+    ('SK', '0012345678', True),
+    ('SK', '531231123', True),
+    ('SK', '6306151234', True),
+    ('SK', '2021853504', True),
+    ('SM', '12345', True),
+    ('UA', '12345678', True),
 ]
 
 VIES_NUMBERS = [
@@ -94,8 +185,12 @@ class VatNumberTest(unittest.TestCase):
         '''
         Test VAT numbers
         '''
-        for code, number in VAT_NUMBERS:
-            self.assert_(vatnumber.check_vat(code + number), code + number)
+        for code, number, result in VAT_NUMBERS:
+            if result:
+                test = self.assert_
+            else:
+                test = self.assertFalse
+            test(vatnumber.check_vat(code + number), code + number)
 
     def test_vies(self):
         '''
@@ -104,5 +199,11 @@ class VatNumberTest(unittest.TestCase):
         for vat in VIES_NUMBERS:
             self.assert_(vatnumber.check_vies(vat))
 
+    def test_countries(self):
+        '''
+        Test countries
+        '''
+        vatnumber.countries()
+
 if __name__ == '__main__':
     unittest.main()
commit e2eb1b7799aad931f2d13d2f1256a6881752de4d
Author: Daniel Baumann <daniel at debian.org>
Date:   Mon May 31 08:15:50 2010 +0200

    Adding upstream version 0.6.

diff --git a/CHANGELOG b/CHANGELOG
index 7fd1a12..97507d5 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,11 @@
+Version 0.6 - 2010-05-30
+* Add generic check_vat method
+* Replace SOAPpy by suds
+* Add GB validation for {GB,HA}888 8xxx yy format
+* Add GB validation for branch traders 12 digits
+* Update vies SOAP URL and add unittest
+* Add Check Russia VAT number
+
 Version 0.5 - 2009-11-13
 * Add Check Chile RUT number for issue5
 * Add Check Colombian RUT number for issue4
diff --git a/COPYRIGHT b/COPYRIGHT
index 9f89bf3..636799b 100644
--- a/COPYRIGHT
+++ b/COPYRIGHT
@@ -1,5 +1,5 @@
-Copyright (c) 2008-2009 Cédric Krier.
-Copyright (c) 2008-2009 B2CK.
+Copyright (c) 2008-2010 Cédric Krier.
+Copyright (c) 2008-2010 B2CK.
 
 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
diff --git a/INSTALL b/INSTALL
index f86c8aa..499bfa0 100644
--- a/INSTALL
+++ b/INSTALL
@@ -5,7 +5,7 @@ Prerequisites
 -------------
 
  * Python (http://www.python.org/)
- * SOAPpy (http://pywebsvcs.sourceforge.net/)
+ * suds (https://fedorahosted.org/suds/)
 
 Installation
 ------------
diff --git a/PKG-INFO b/PKG-INFO
index 0fd16d5..76bfeaa 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,13 +1,37 @@
 Metadata-Version: 1.0
 Name: vatnumber
-Version: 0.5
+Version: 0.6
 Summary: Python module to validate VAT numbers
 Home-page: http://code.google.com/p/vatnumber/
 Author: B2CK
 Author-email: info at b2ck.com
 License: GPL-3
 Download-URL: http://code.google.com/p/vatnumber/downloads/
-Description: UNKNOWN
+Description: vatnumber
+        =========
+        
+        Python module to validate VAT numbers.
+        
+        Nutshell
+        --------
+        
+        Here a simple example to validate VAT numbers format::
+        
+        >>> import vatnumber
+        >>> vatnumber.check_vat('BE0123456749')
+        True
+        
+        Here a simple example to validate European VAT through VIES service::
+        
+        >>> import vatnumber
+        >>> vatnumber.check_vies('BE0897290877')
+        True
+        
+        
+        For more information please visit the `vatnumber website_`.
+        
+        .. _vatnumber website: http://code.google.com/p/vatnumber/
+        
 Platform: UNKNOWN
 Classifier: Development Status :: 5 - Production/Stable
 Classifier: Intended Audience :: Developers
diff --git a/README b/README
index ced6901..0696fe0 100644
--- a/README
+++ b/README
@@ -3,6 +3,22 @@ vatnumber
 
 Python module to validate VAT numbers.
 
-For more information please visit the vatnumber web site:
+Nutshell
+--------
 
-    <http://code.google.com/p/vatnumber/>
+Here a simple example to validate VAT numbers format::
+
+    >>> import vatnumber
+    >>> vatnumber.check_vat('BE0123456749')
+    True
+
+Here a simple example to validate European VAT through VIES service::
+
+    >>> import vatnumber
+    >>> vatnumber.check_vies('BE0897290877')
+    True
+
+
+For more information please visit the `vatnumber website_`.
+
+.. _vatnumber website: http://code.google.com/p/vatnumber/
diff --git a/setup.py b/setup.py
index b5423d8..e726086 100644
--- a/setup.py
+++ b/setup.py
@@ -2,17 +2,22 @@
 #This file is part of vatnumber.  The COPYRIGHT file at the top level of
 #this repository contains the full copyright notices and license terms.
 
-from setuptools import setup
+import os
+from setuptools import setup, find_packages
 import vatnumber
 
+def read(fname):
+    return open(os.path.join(os.path.dirname(__file__), fname)).read()
+
 setup(name='vatnumber',
         version=vatnumber.__version__,
         author='B2CK',
         author_email='info at b2ck.com',
         url="http://code.google.com/p/vatnumber/",
         description="Python module to validate VAT numbers",
+        long_description=read('README'),
         download_url="http://code.google.com/p/vatnumber/downloads/",
-        py_modules=['vatnumber'],
+        packages=find_packages(),
         classifiers=[
             'Development Status :: 5 - Production/Stable',
             'Intended Audience :: Developers',
@@ -24,5 +29,8 @@ setup(name='vatnumber',
             'Topic :: Software Development :: Libraries :: Python Modules',
             ],
         license='GPL-3',
-        test_suite="tests",
+        extras_require={
+            'suds': ['suds'],
+        },
+        test_suite="vatnumber.tests",
     )
diff --git a/vatnumber.egg-info/PKG-INFO b/vatnumber.egg-info/PKG-INFO
index 0fd16d5..76bfeaa 100644
--- a/vatnumber.egg-info/PKG-INFO
+++ b/vatnumber.egg-info/PKG-INFO
@@ -1,13 +1,37 @@
 Metadata-Version: 1.0
 Name: vatnumber
-Version: 0.5
+Version: 0.6
 Summary: Python module to validate VAT numbers
 Home-page: http://code.google.com/p/vatnumber/
 Author: B2CK
 Author-email: info at b2ck.com
 License: GPL-3
 Download-URL: http://code.google.com/p/vatnumber/downloads/
-Description: UNKNOWN
+Description: vatnumber
+        =========
+        
+        Python module to validate VAT numbers.
+        
+        Nutshell
+        --------
+        
+        Here a simple example to validate VAT numbers format::
+        
+        >>> import vatnumber
+        >>> vatnumber.check_vat('BE0123456749')
+        True
+        
+        Here a simple example to validate European VAT through VIES service::
+        
+        >>> import vatnumber
+        >>> vatnumber.check_vies('BE0897290877')
+        True
+        
+        
+        For more information please visit the `vatnumber website_`.
+        
+        .. _vatnumber website: http://code.google.com/p/vatnumber/
+        
 Platform: UNKNOWN
 Classifier: Development Status :: 5 - Production/Stable
 Classifier: Intended Audience :: Developers
diff --git a/vatnumber.egg-info/SOURCES.txt b/vatnumber.egg-info/SOURCES.txt
index 639f54a..93e4a11 100644
--- a/vatnumber.egg-info/SOURCES.txt
+++ b/vatnumber.egg-info/SOURCES.txt
@@ -5,8 +5,10 @@ LICENSE
 MANIFEST.in
 README
 setup.py
-vatnumber.py
+vatnumber/__init__.py
+vatnumber/tests.py
 vatnumber.egg-info/PKG-INFO
 vatnumber.egg-info/SOURCES.txt
 vatnumber.egg-info/dependency_links.txt
+vatnumber.egg-info/requires.txt
 vatnumber.egg-info/top_level.txt
\ No newline at end of file
diff --git a/vatnumber.egg-info/requires.txt b/vatnumber.egg-info/requires.txt
new file mode 100644
index 0000000..6449f6c
--- /dev/null
+++ b/vatnumber.egg-info/requires.txt
@@ -0,0 +1,4 @@
+
+
+[suds]
+suds
\ No newline at end of file
diff --git a/vatnumber.py b/vatnumber/__init__.py
similarity index 93%
rename from vatnumber.py
rename to vatnumber/__init__.py
index 9b8f6a5..c205c16 100644
--- a/vatnumber.py
+++ b/vatnumber/__init__.py
@@ -6,8 +6,8 @@ http://sima-pc.com/nif.php
 http://en.wikipedia.org/wiki/Vat_number
 '''
 
-__version__ = '0.5'
-VIES_URL='http://ec.europa.eu/taxation_customs/vies/api/checkVatPort?wsdl'
+__version__ = '0.6'
+VIES_URL='http://ec.europa.eu/taxation_customs/vies/services/checkVatService.wsdl'
 
 def countries():
     '''
@@ -536,48 +536,61 @@ def check_vat_gb(vat):
                 return False
             return True
         return False
-    elif len(vat) in (9, 10):
+    elif len(vat) == 11 \
+            and vat[0:6] in ('GD8888', 'HA8888'):
+        try:
+            int(vat[6:11])
+        except ValueError:
+            return False
+        if vat[0:2] == 'GD' \
+                and int(vat[6:9]) >= 500:
+            return False
+        elif vat[0:2] == 'HA' \
+                and int(vat[6:9]) < 500:
+            return False
+        if int(vat[6:9]) % 97 == int(vat[9:11]):
+            return True
+        return False
+    elif len(vat) in (12, 13) \
+            and vat[0:3] in ('000', '001'):
         try:
             int(vat)
         except ValueError:
             return False
 
-        if int(vat[0:7]) < 1:
+        if int(vat[3:10]) < 1:
             return False
-        if int(vat[0:7]) > 19999 and int(vat[0:7]) < 1000000:
+        if int(vat[3:10]) > 19999 and int(vat[3:10]) < 1000000:
             return False
-        if int(vat[7:9]) > 97:
+        if int(vat[10:12]) > 97:
             return False
-        if len(vat) == 10 and int(vat[9]) != 3:
+        if len(vat) == 13 and int(vat[12]) != 3:
             return False
 
-        check_sum = 8 * int(vat[0]) + 7 * int(vat[1]) + 6 * int(vat[2]) + \
-                5 * int(vat[3]) + 4 * int(vat[4]) + 3 * int(vat[5]) + \
-                2 * int(vat[6]) + 10 * int(vat[7]) + int(vat[8])
+        check_sum = 8 * int(vat[3]) + 7 * int(vat[4]) + 6 * int(vat[5]) + \
+                5 * int(vat[6]) + 4 * int(vat[7]) + 3 * int(vat[8]) + \
+                2 * int(vat[9]) + 10 * int(vat[10]) + int(vat[11])
         if check_sum % 97 != 0:
             return False
         return True
-    elif len(vat) in (12, 13):
+    elif len(vat) in (9, 10, 12):
         try:
             int(vat)
         except ValueError:
             return False
 
-        if int(vat[0:3]) not in (0, 1):
-            return False
-
-        if int(vat[3:10]) < 1:
+        if int(vat[0:7]) < 1:
             return False
-        if int(vat[3:10]) > 19999 and int(vat[3:10]) < 1000000:
+        if int(vat[0:7]) > 19999 and int(vat[0:7]) < 1000000:
             return False
-        if int(vat[10:12]) > 97:
+        if int(vat[7:9]) > 97:
             return False
-        if len(vat) == 13 and int(vat[12]) != 3:
+        if len(vat) == 10 and int(vat[9]) != 3:
             return False
 
-        check_sum = 8 * int(vat[3]) + 7 * int(vat[4]) + 6 * int(vat[5]) + \
-                5 * int(vat[6]) + 4 * int(vat[7]) + 3 * int(vat[8]) + \
-                2 * int(vat[9]) + 10 * int(vat[10]) + int(vat[11])
+        check_sum = 8 * int(vat[0]) + 7 * int(vat[1]) + 6 * int(vat[2]) + \
+                5 * int(vat[3]) + 4 * int(vat[4]) + 3 * int(vat[5]) + \
+                2 * int(vat[6]) + 10 * int(vat[7]) + int(vat[8])
         if check_sum % 97 != 0:
             return False
         return True
@@ -1088,13 +1101,57 @@ def check_vat_uk(vat):
     '''
     return check_vat_gb(vat)
 
+def check_vat_ru(vat):
+    '''
+    Check Russia VAT number.
+    '''
+    if len(vat) != 10 and len(vat) != 12:
+        return False
+    try:
+        int(vat)
+    except ValueError:
+        return False
+
+    if len(vat) == 10:
+        check_sum = 2 * int(vat[0]) + 4 * int(vat[1]) + 10 * int(vat[2]) + \
+                3 * int(vat[3]) + 5 * int(vat[4]) + 9 * int(vat[5]) + \
+                4 * int(vat[6]) + 6 * int(vat[7]) + 8 * int(vat[8])
+        check = check_sum % 11
+        if check % 10 != int(vat[9]):
+            return False
+    else:
+        check_sum1 = 7 * int(vat[0]) + 2 * int(vat[1]) + 4 * int(vat[2]) + \
+                10 * int(vat[3]) + 3 * int(vat[4]) + 5 * int(vat[5]) + \
+                9 * int(vat[6]) + 4 * int(vat[7]) + 6 * int(vat[8]) + \
+                8 * int(vat[9])
+        check = check_sum1 % 11
+
+        if check != int(vat[10]):
+            return False
+        check_sum2 = 3 * int(vat[0]) + 7 * int(vat[1]) + 2 * int(vat[2]) + \
+                4 * int(vat[3]) + 10 * int(vat[4]) + 3 * int(vat[5]) + \
+                5 * int(vat[6]) + 9 * int(vat[7]) + 4 * int(vat[8]) + \
+                6 * int(vat[9]) + 8 * int(vat[10])
+        check = check_sum2 % 11
+        if check != int(vat[11]):
+            return False
+    return True
+
+def check_vat(vat):
+    '''
+    Check VAT number.
+    '''
+    code = vat[:2].lower()
+    number = vat[2:]
+    return globals()['check_vat_%s' % code](number)
+
 def check_vies(vat):
     '''
     Check VAT number for EU member state using the SOAP Service
     '''
-    from SOAPpy import WSDL
+    from suds.client import Client
+    client = Client(VIES_URL)
     code = vat[:2]
     number = vat[2:]
-    server = WSDL.Proxy(VIES_URL)
-    res = server.checkVat(code, number)
+    res = client.service.checkVat(countryCode=code, vatNumber=number)
     return bool(res['valid'])
diff --git a/vatnumber/tests.py b/vatnumber/tests.py
new file mode 100644
index 0000000..2152edb
--- /dev/null
+++ b/vatnumber/tests.py
@@ -0,0 +1,108 @@
+#This file is part of vatnumber.  The COPYRIGHT file at the top level of
+#this repository contains the full copyright notices and license terms.
+'''
+Unit test for vatnumber
+'''
+
+import unittest
+import vatnumber
+
+VAT_NUMBERS = [
+    ('AT', 'U12345675'),
+    ('AL', 'K99999999L'),
+    ('BE', '0123456749'),
+    ('BG', '1234567892'),
+    ('BG', '175074752'),
+    ('BG', '131202360'),
+    ('BG', '040683212'),
+    ('CL', '334441113'),
+    ('CO', '9001279338'),
+    ('CY', '12345678F'),
+    ('CZ', '12345679'),
+    ('CZ', '612345670'),
+    ('CZ', '991231123'),
+    ('CZ', '6306150004'),
+    ('DE', '123456788'),
+    ('DK', '12345674'),
+    ('EE', '123456780'),
+    ('ES', 'A12345674'),
+    ('ES', 'P1234567D'),
+    ('ES', 'K1234567L'),
+    ('ES', 'R9600075G'),
+    ('ES', 'W4003922D'),
+    ('ES', 'V99218067'),
+    ('ES', 'U99216632'),
+    ('ES', 'J99216582'),
+    ('ES', 'U99216426'),
+    ('ES', '12345678Z'),
+    ('ES', 'X5277343Q'),
+    ('ES', 'Y5277343F'),
+    ('ES', 'Z5277343K'),
+    ('FI', '12345671'),
+    ('FR', '32123456789'),
+    ('FR', '2H123456789'),
+    ('GB', 'GD123'),
+    ('GB', 'GD888812326'),
+    ('GB', 'HA567'),
+    ('GB', 'HA888856782'),
+    ('GB', '123456782'),
+    ('GB', '1234567823'),
+    ('GB', '001123456782'),
+    ('GB', '0011234567823'),
+    ('GB', '242338087388'),
+    ('GR', '12345670'),
+    ('GR', '123456783'),
+    ('HU', '12345676'),
+    ('IE', '7A12345J'),
+    ('IE', '1234567T'),
+    ('IT', '12345670017'),
+    ('LT', '123456715'),
+    ('LT', '123456789011'),
+    ('LU', '12345613'),
+    ('LV', '41234567891'),
+    ('LV', '15066312345'),
+    ('MT', '12345634'),
+    ('NL', '123456782B90'),
+    ('PL', '1234567883'),
+    ('PT', '123456789'),
+    ('RO', '24736200'),
+    ('RO', '1234567897'),
+    ('RO', '1630615123457'),
+    ('RU', '5505035011'),
+    ('RU', '550501929014'),
+    ('SE', '123456789701'),
+    ('SI', '12345679'),
+    ('SK', '0012345675'),
+    ('SK', '0012345678'),
+    ('SK', '531231123'),
+    ('SK', '6306151234'),
+    ('SM', '12345'),
+    ('UA', '12345678'),
+]
+
+VIES_NUMBERS = [
+    'BE0897290877',
+]
+
+
+class VatNumberTest(unittest.TestCase):
+    '''
+    Test Case for vatnumber
+    '''
+
+    def test_vat_numbers(self):
+        '''
+        Test VAT numbers
+        '''
+        for code, number in VAT_NUMBERS:
+            self.assert_(vatnumber.check_vat(code + number), code + number)
+
+    def test_vies(self):
+        '''
+        Test vies
+        '''
+        for vat in VIES_NUMBERS:
+            self.assert_(vatnumber.check_vies(vat))
+
+if __name__ == '__main__':
+    unittest.main()
commit 3c660977e0a99c35a56a1b59bd957edde39d0ac7
Author: Daniel Baumann <daniel at debian.org>
Date:   Mon Nov 16 20:31:38 2009 +0100

    Adding upstream version 0.5.

diff --git a/CHANGELOG b/CHANGELOG
index bfab834..7fd1a12 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,8 @@
+Version 0.5 - 2009-11-13
+* Add Check Chile RUT number for issue5
+* Add Check Colombian RUT number for issue4
+* Fix Portugal VAT when check number is 11
+
 Version 0.4 - 2009-03-30
 * Update Spain test for issue3 thanks to carlos at pemas.es
 * Add VIES check with the SOAP Service of EU
diff --git a/COPYRIGHT b/COPYRIGHT
index 1e5eeaa..9f89bf3 100644
--- a/COPYRIGHT
+++ b/COPYRIGHT
@@ -1,5 +1,5 @@
-Copyright (c) 2008 Cedric Krier.
-Copyright (c) 2008 B2CK.
+Copyright (c) 2008-2009 Cédric Krier.
+Copyright (c) 2008-2009 B2CK.
 
 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
diff --git a/PKG-INFO b/PKG-INFO
index 4d895b9..0fd16d5 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.0
 Name: vatnumber
-Version: 0.4
+Version: 0.5
 Summary: Python module to validate VAT numbers
 Home-page: http://code.google.com/p/vatnumber/
 Author: B2CK
diff --git a/vatnumber.egg-info/PKG-INFO b/vatnumber.egg-info/PKG-INFO
index 4d895b9..0fd16d5 100644
--- a/vatnumber.egg-info/PKG-INFO
+++ b/vatnumber.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.0
 Name: vatnumber
-Version: 0.4
+Version: 0.5
 Summary: Python module to validate VAT numbers
 Home-page: http://code.google.com/p/vatnumber/
 Author: B2CK
diff --git a/vatnumber.py b/vatnumber.py
index e5b08f6..9b8f6a5 100644
--- a/vatnumber.py
+++ b/vatnumber.py
@@ -6,7 +6,7 @@ http://sima-pc.com/nif.php
 http://en.wikipedia.org/wiki/Vat_number
 '''
 
-__version__ = '0.4'
+__version__ = '0.5'
 VIES_URL='http://ec.europa.eu/taxation_customs/vies/api/checkVatPort?wsdl'
 
 def countries():
@@ -113,6 +113,46 @@ def check_vat_bg(vat):
         return False
     return True
 
+def check_vat_cl(rut):
+    '''
+    Check Chile RUT number.
+    '''
+    try:
+        int(str(rut)[:len(str(rut))-1])
+    except ValueError:
+        return False
+    sum = 0
+    RUTLen = len(str(rut))
+    for i in range (RUTLen - 2, -1, -1):
+        sum += int(str(rut)[i]) * (((RUTLen - 2 - i) % 6) + 2)
+    check = 11 - (sum % 11)
+    if check == 11:
+        return str(rut)[len(str(rut)) -1] == '0'
+    elif check == 10:
+        return str(rut)[len(str(rut)) -1].upper() == 'K'
+    else:
+        return str(check) == str(rut)[len(str(rut)) -1]
+
+def check_vat_co(rut):
+    '''
+    Check Colombian RUT number.
+    '''
+    if len(str(rut)) != 10:
+        return False
+    try:
+        int(rut)
+    except ValueError:
+        return False
+    nums = [3, 7, 13, 17, 19, 23, 29, 37, 41, 43, 47, 53, 59, 67, 71]
+    sum = 0
+    RUTLen = len(str(rut))
+    for i in range (RUTLen - 2, -1, -1):
+        sum += int(str(rut)[i]) * nums [RUTLen - 2 - i]
+    if sum % 11 > 1:
+         return str(rut)[RUTLen - 1] == str(11 - (sum % 11))
+    else:
+         return str(rut)[RUTLen - 1] == str(sum % 11)
+
 def check_vat_cy(vat):
     '''
     Check Cyprus VAT number.
@@ -869,7 +909,7 @@ def check_vat_pt(vat):
             6 * int(vat[3]) + 5 * int(vat[4]) + 4 * int(vat[5]) + \
             3 * int(vat[6]) + 2 * int(vat[7])
     check = 11 - (check_sum % 11)
-    if check == 10:
+    if check == 10 or check == 11:
         check = 0
     if check != int(vat[8]):
         return False
commit 673e6d47af43a292a07c04a855da5ab5c3b0f2f5
Author: Daniel Baumann <daniel at debian.org>
Date:   Mon Mar 30 11:03:11 2009 +0200

    Adding upstream version 0.4.

diff --git a/CHANGELOG b/CHANGELOG
index a40c6e2..bfab834 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,8 @@
+Version 0.4 - 2009-03-30
+* Update Spain test for issue3 thanks to carlos at pemas.es
+* Add VIES check with the SOAP Service of EU
+* Add test for Bulgaria VAT number with length of 9
+
 Version 0.3 - 2009-03-23
 * Fix check_vat_ro for vat number with less than 10 digits
 
diff --git a/INSTALL b/INSTALL
new file mode 100644
index 0000000..f86c8aa
--- /dev/null
+++ b/INSTALL
@@ -0,0 +1,26 @@
+Installing vatnumber
+====================
+
+Prerequisites
+-------------
+
+ * Python (http://www.python.org/)
+ * SOAPpy (http://pywebsvcs.sourceforge.net/)
+
+Installation
+------------
+
+Once you've downloaded and unpacked the vatnumber source release, enter the
+directory where the archive was unpacked, and run:
+
+    python setup.py install
+
+Note that you may need administrator/root privileges for this step, as
+this command will by default attempt to install module to the Python
+site-packages directory on your system.
+
+For advanced options, please refer to the easy_install and/or the distutils
+documentation:
+
+  http://peak.telecommunity.com/DevCenter/EasyInstall
+  http://docs.python.org/inst/inst.html
diff --git a/MANIFEST.in b/MANIFEST.in
index 7fbc498..57aaa1a 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -2,3 +2,4 @@ include LICENSE
 include COPYRIGHT
 include README
 include CHANGELOG
+include INSTALL
diff --git a/PKG-INFO b/PKG-INFO
index f910dfd..4d895b9 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.0
 Name: vatnumber
-Version: 0.3
+Version: 0.4
 Summary: Python module to validate VAT numbers
 Home-page: http://code.google.com/p/vatnumber/
 Author: B2CK
diff --git a/vatnumber.egg-info/PKG-INFO b/vatnumber.egg-info/PKG-INFO
index f910dfd..4d895b9 100644
--- a/vatnumber.egg-info/PKG-INFO
+++ b/vatnumber.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.0
 Name: vatnumber
-Version: 0.3
+Version: 0.4
 Summary: Python module to validate VAT numbers
 Home-page: http://code.google.com/p/vatnumber/
 Author: B2CK
diff --git a/vatnumber.egg-info/SOURCES.txt b/vatnumber.egg-info/SOURCES.txt
index 79c6e7d..639f54a 100644
--- a/vatnumber.egg-info/SOURCES.txt
+++ b/vatnumber.egg-info/SOURCES.txt
@@ -1,5 +1,6 @@
 CHANGELOG
 COPYRIGHT
+INSTALL
 LICENSE
 MANIFEST.in
 README
diff --git a/vatnumber.py b/vatnumber.py
index cb61493..e5b08f6 100644
--- a/vatnumber.py
+++ b/vatnumber.py
@@ -6,7 +6,8 @@ http://sima-pc.com/nif.php
 http://en.wikipedia.org/wiki/Vat_number
 '''
 
-__version__ = '0.3'
+__version__ = '0.4'
+VIES_URL='http://ec.europa.eu/taxation_customs/vies/api/checkVatPort?wsdl'
 
 def countries():
     '''
@@ -88,6 +89,9 @@ def check_vat_bg(vat):
     '''
     Check Bulgaria VAT number.
     '''
+    if len(vat) == 9:
+        #XXX don't know any rules for this length
+        return True
     if len(vat) != 10:
         return False
     try:
@@ -344,7 +348,7 @@ def check_vat_es(vat):
         23: 'E',
     }
 
-    if vat[0] in ('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'):
+    if vat[0] in ('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'U', 'V'):
         try:
             int(vat[1:])
         except ValueError:
@@ -359,7 +363,7 @@ def check_vat_es(vat):
         if check != int(vat[8]):
             return False
         return True
-    elif vat[0] in ('N', 'P', 'Q', 'S'):
+    elif vat[0] in ('N', 'P', 'Q', 'R', 'S', 'W'):
         try:
             int(vat[1:8])
         except ValueError:
@@ -373,12 +377,19 @@ def check_vat_es(vat):
         if check != vat[8]:
             return False
         return True
-    elif vat[0] in ('K', 'L', 'M', 'X'):
+    elif vat[0] in ('K', 'L', 'M', 'X', 'Y', 'Z'):
+        if vat[0] == 'Y':
+            check_value = '1' + vat[1:8]
+        elif vat[0] == 'Z':
+            check_value = '2' + vat[1:8]
+        else:
+            check_value = vat[1:8]
+
         try:
-            int(vat[1:8])
+            int(check_value)
         except ValueError:
             return False
-        check = 1 + (int(vat[1:8]) % 23)
+        check = 1 + (int(check_value) % 23)
 
         check = conv[check]
         if check != vat[8]:
@@ -1036,3 +1047,14 @@ def check_vat_uk(vat):
     Check United Kingdom VAT number.
     '''
     return check_vat_gb(vat)
+
+def check_vies(vat):
+    '''
+    Check VAT number for EU member state using the SOAP Service
+    '''
+    from SOAPpy import WSDL
+    code = vat[:2]
+    number = vat[2:]
+    server = WSDL.Proxy(VIES_URL)
+    res = server.checkVat(code, number)
+    return bool(res['valid'])
commit 9cd6befe00514d3e081f065861878a82ec3d3027
Author: Daniel Baumann <daniel at debian.org>
Date:   Mon Mar 30 10:59:53 2009 +0200

    Adding upstream version 0.3.

diff --git a/CHANGELOG b/CHANGELOG
index 86ba200..a40c6e2 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,6 @@
+Version 0.3 - 2009-03-23
+* Fix check_vat_ro for vat number with less than 10 digits
+
 Version 0.2 - 2008-09-29
 * Add check_vat_uk function
 * Improve Belgium vat check as first number must be 0
diff --git a/PKG-INFO b/PKG-INFO
index 4b122ad..f910dfd 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.0
 Name: vatnumber
-Version: 0.2
+Version: 0.3
 Summary: Python module to validate VAT numbers
 Home-page: http://code.google.com/p/vatnumber/
 Author: B2CK
diff --git a/vatnumber.egg-info/PKG-INFO b/vatnumber.egg-info/PKG-INFO
index 4b122ad..f910dfd 100644
--- a/vatnumber.egg-info/PKG-INFO
+++ b/vatnumber.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.0
 Name: vatnumber
-Version: 0.2
+Version: 0.3
 Summary: Python module to validate VAT numbers
 Home-page: http://code.google.com/p/vatnumber/
 Author: B2CK
diff --git a/vatnumber.py b/vatnumber.py
index 147261d..cb61493 100644
--- a/vatnumber.py
+++ b/vatnumber.py
@@ -6,7 +6,7 @@ http://sima-pc.com/nif.php
 http://en.wikipedia.org/wiki/Vat_number
 '''
 
-__version__ = '0.2'
+__version__ = '0.3'
 
 def countries():
     '''
@@ -873,7 +873,8 @@ def check_vat_ro(vat):
     except ValueError:
         return False
 
-    if len(vat) == 10:
+    if len(vat) >= 2 and len(vat) <= 10:
+        vat = (10 - len(vat)) * '0' + vat
         check_sum = 7 * int(vat[0]) + 5 * int(vat[1]) + 3 * int(vat[2]) + \
                 2 * int(vat[3]) + 1 * int(vat[4]) + 7 * int(vat[5]) + \
                 5 * int(vat[6]) + 3 * int(vat[7]) + 2 * int(vat[8])
-- 
vatnumber



More information about the tryton-debian-vcs mailing list