Jelajahi Sumber

Impl. ES checker

Radu Boncea 6 tahun lalu
induk
melakukan
990087ef62

+ 2 - 1
.gitignore

@@ -246,4 +246,5 @@ GitHub.sublime-settings
 # Ignore all local history of files
 .history
 
-# End of https://www.gitignore.io/api/python,sublimetext,pycharm+all,visualstudiocode
+# End of https://www.gitignore.io/api/python,sublimetext,pycharm+all,visualstudiocode
+doc/~$ES-VAT Validation Routines-v15.0.doc

+ 18 - 1
pyVat/api.py

@@ -1,3 +1,20 @@
+# Copyright 2018 Agile Geeks
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+# and associated documentation files (the "Software"), to deal in the Software without restriction,
+# including without limitation the rights to use, copy, modify, merge, publish, distribute,
+# sublicense, and/or sell copies of the Software, and to permit persons to whom the Software
+# is furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in all copies or substantial
+# portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
+# LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
+# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
 from __future__ import unicode_literals, print_function
 
 import re
@@ -102,7 +119,7 @@ class Validator(object):
             if vat_number[:2].upper() == vat_country_code:
                 vat_number = vat_number[2:]
 
-        return vat_number,vat_country_code
+        return vat_number.upper(),vat_country_code.upper()
 
     def validate(self):
         try:

+ 17 - 0
pyVat/validators/at.py

@@ -1,3 +1,20 @@
+# Copyright 2018 Agile Geeks
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+# and associated documentation files (the "Software"), to deal in the Software without restriction,
+# including without limitation the rights to use, copy, modify, merge, publish, distribute,
+# sublicense, and/or sell copies of the Software, and to permit persons to whom the Software
+# is furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in all copies or substantial
+# portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
+# LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
+# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
 import re
 from .generic import GenericValidator
 

+ 17 - 0
pyVat/validators/be.py

@@ -1,3 +1,20 @@
+# Copyright 2018 Agile Geeks
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+# and associated documentation files (the "Software"), to deal in the Software without restriction,
+# including without limitation the rights to use, copy, modify, merge, publish, distribute,
+# sublicense, and/or sell copies of the Software, and to permit persons to whom the Software
+# is furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in all copies or substantial
+# portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
+# LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
+# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
 import re
 from .generic import GenericValidator
 

+ 17 - 0
pyVat/validators/bg.py

@@ -1,3 +1,20 @@
+# Copyright 2018 Agile Geeks
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+# and associated documentation files (the "Software"), to deal in the Software without restriction,
+# including without limitation the rights to use, copy, modify, merge, publish, distribute,
+# sublicense, and/or sell copies of the Software, and to permit persons to whom the Software
+# is furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in all copies or substantial
+# portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
+# LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
+# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
 import re
 from .generic import GenericValidator
 

+ 17 - 0
pyVat/validators/cy.py

@@ -1,3 +1,20 @@
+# Copyright 2018 Agile Geeks
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+# and associated documentation files (the "Software"), to deal in the Software without restriction,
+# including without limitation the rights to use, copy, modify, merge, publish, distribute,
+# sublicense, and/or sell copies of the Software, and to permit persons to whom the Software
+# is furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in all copies or substantial
+# portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
+# LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
+# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
 import re
 from .generic import GenericValidator
 

+ 17 - 0
pyVat/validators/cz.py

@@ -1,3 +1,20 @@
+# Copyright 2018 Agile Geeks
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+# and associated documentation files (the "Software"), to deal in the Software without restriction,
+# including without limitation the rights to use, copy, modify, merge, publish, distribute,
+# sublicense, and/or sell copies of the Software, and to permit persons to whom the Software
+# is furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in all copies or substantial
+# portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
+# LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
+# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
 import re
 import math
 import calendar

+ 17 - 0
pyVat/validators/de.py

@@ -1,3 +1,20 @@
+# Copyright 2018 Agile Geeks
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+# and associated documentation files (the "Software"), to deal in the Software without restriction,
+# including without limitation the rights to use, copy, modify, merge, publish, distribute,
+# sublicense, and/or sell copies of the Software, and to permit persons to whom the Software
+# is furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in all copies or substantial
+# portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
+# LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
+# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
 import re
 from .generic import GenericValidator
 

+ 17 - 0
pyVat/validators/dk.py

@@ -1,3 +1,20 @@
+# Copyright 2018 Agile Geeks
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+# and associated documentation files (the "Software"), to deal in the Software without restriction,
+# including without limitation the rights to use, copy, modify, merge, publish, distribute,
+# sublicense, and/or sell copies of the Software, and to permit persons to whom the Software
+# is furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in all copies or substantial
+# portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
+# LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
+# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
 import re
 from .generic import GenericValidator
 

+ 17 - 0
pyVat/validators/ee.py

@@ -1,3 +1,20 @@
+# Copyright 2018 Agile Geeks
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+# and associated documentation files (the "Software"), to deal in the Software without restriction,
+# including without limitation the rights to use, copy, modify, merge, publish, distribute,
+# sublicense, and/or sell copies of the Software, and to permit persons to whom the Software
+# is furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in all copies or substantial
+# portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
+# LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
+# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
 import re
 import math
 from .generic import GenericValidator

+ 111 - 4
pyVat/validators/es.py

@@ -1,3 +1,20 @@
+# Copyright 2018 Agile Geeks
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+# and associated documentation files (the "Software"), to deal in the Software without restriction,
+# including without limitation the rights to use, copy, modify, merge, publish, distribute,
+# sublicense, and/or sell copies of the Software, and to permit persons to whom the Software
+# is furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in all copies or substantial
+# portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
+# LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
+# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
 import re
 import math
 from .generic import GenericValidator
@@ -14,8 +31,8 @@ class Validator(GenericValidator):
         if super(Validator, self).validate(vat_number) is False:
             return False
 
-
         vat_number = str(vat_number)
+        checknum = vat_number[8].upper()
 
         try:
             int( vat_number[8] )
@@ -24,6 +41,13 @@ class Validator(GenericValidator):
         else:
             c9_is_number = True
 
+        try:
+            int( vat_number[0] )
+        except:
+            c1_is_number = False
+        else:
+            c1_is_number = True
+
         c1 = vat_number[0].upper()
         if c9_is_number:
             if c1 not in ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'U', 'V']:
@@ -33,8 +57,91 @@ class Validator(GenericValidator):
                           'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'W', 'X', 'Y', 'Z' ]:
                 return False
 
-
-        # case A)
+        # Juridical entities other than national ones
         if c9_is_number is False and c1 in ['A', 'B', 'C', 'D', 'E', 'F', 'G',
                                             'H', 'N', 'P', 'Q', 'R', 'S', 'W']:
-            s1 = int(vat_number[2]) + int(vat_number[4]) + int(vat_number[6])
+            s1 = int(vat_number[2]) + int(vat_number[4]) + int(vat_number[6])
+            s2 = 0
+            for i in range(1,8,2):
+                digit = int(vat_number[i])
+                s2 = s2 + int(digit/5) + (2 * digit) % 10
+            r = 10 - (s1 + s2) % 10
+            last_digit_mapping = {
+                1: 'A',
+                2: 'B',
+                3: 'C',
+                4: 'D',
+                5: 'E',
+                6: 'F',
+                7: 'G',
+                8: 'H',
+                9: 'I',
+                10: 'J'
+            }
+            if checknum == last_digit_mapping[r]:
+                return True
+
+        # # Physical persons
+        if c9_is_number is False:
+            if c1 in ['K', 'L', 'M', 'X', 'Y', 'Z'] or c1_is_number:
+                new_c1 = c1
+                if new_c1 == 'Y':
+                    new_c1 = 1
+                if new_c1 == 'Z':
+                    new_c1 = 2
+                new_vat_number = str(new_c1) + vat_number[1:]
+
+                try:
+                    int(new_c1)
+                except:
+                    new_c1_is_number = False
+                else:
+                    new_c1_is_number = True
+
+                if new_c1_is_number:
+                    r = sum(int(i) for i in new_vat_number[:8]) %23 + 1
+                else:
+                    r = sum(int(i) for i in new_vat_number[1:8]) % 23 + 1
+                last_digit_mapping = {
+                    1: 'T',
+                    2: 'R',
+                    3: 'W',
+                    4: 'A',
+                    5: 'G',
+                    6: 'M',
+                    7: 'Y',
+                    8: 'F',
+                    9: 'P',
+                    10: 'D',
+                    11: 'X',
+                    12: 'B',
+                    13: 'N',
+                    14: 'J',
+                    15: 'Z',
+                    16: 'S',
+                    17: 'Q',
+                    18: 'V',
+                    19: 'H',
+                    20: 'L',
+                    21: 'C',
+                    22: 'K',
+                    23: 'E'
+                }
+                if checknum == last_digit_mapping[r]:
+                    return True
+
+        if c9_is_number:
+            checknum = int(vat_number[8])
+            s1 = int(vat_number[2]) + int(vat_number[4]) + int(vat_number[6])
+            s2 = 0
+            for i in range(1, 8, 2):
+                digit = int(vat_number[i])
+                s2 = s2 + int(digit / 5) + (2 * digit) % 10
+            r = 10 - (s1 + s2) % 10
+
+            return checknum == (r % 10)
+
+        return False
+
+
+

+ 17 - 0
pyVat/validators/generic.py

@@ -1,3 +1,20 @@
+# Copyright 2018 Agile Geeks
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+# and associated documentation files (the "Software"), to deal in the Software without restriction,
+# including without limitation the rights to use, copy, modify, merge, publish, distribute,
+# sublicense, and/or sell copies of the Software, and to permit persons to whom the Software
+# is furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in all copies or substantial
+# portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
+# LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
+# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
 import re
 
 class GenericValidator(object):

+ 17 - 0
pyVat/validators/gr.py

@@ -1,3 +1,20 @@
+# Copyright 2018 Agile Geeks
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+# and associated documentation files (the "Software"), to deal in the Software without restriction,
+# including without limitation the rights to use, copy, modify, merge, publish, distribute,
+# sublicense, and/or sell copies of the Software, and to permit persons to whom the Software
+# is furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in all copies or substantial
+# portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
+# LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
+# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
 import re
 import math
 from .generic import GenericValidator

+ 17 - 0
pyVat/validators/ro.py

@@ -1,3 +1,20 @@
+# Copyright 2018 Agile Geeks
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+# and associated documentation files (the "Software"), to deal in the Software without restriction,
+# including without limitation the rights to use, copy, modify, merge, publish, distribute,
+# sublicense, and/or sell copies of the Software, and to permit persons to whom the Software
+# is furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in all copies or substantial
+# portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
+# LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
+# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
 import re
 from .generic import GenericValidator
 

+ 65 - 2
tests/test_validator.py

@@ -1,4 +1,20 @@
-#from pyVat.validators.ro import Validator
+# Copyright 2018 Agile Geeks
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+# and associated documentation files (the "Software"), to deal in the Software without restriction,
+# including without limitation the rights to use, copy, modify, merge, publish, distribute,
+# sublicense, and/or sell copies of the Software, and to permit persons to whom the Software
+# is furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in all copies or substantial
+# portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
+# LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
+# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
 import unittest
 
 from pyVat.api import Validator
@@ -37,6 +53,9 @@ class TestValidator(unittest.TestCase):
         validator = Validator('BE0776091950')
         self.assertFalse(validator.validate())
 
+        validator = Validator('BE0842411247')
+        self.assertTrue(validator.validate())
+
     def test_bg(self):
 
         # test legal entity
@@ -66,6 +85,9 @@ class TestValidator(unittest.TestCase):
         self.assertEqual(validator.country_code, 'BG')
         self.assertEqual(validator.vat_number, '0000100153')
 
+        validator = Validator('BG202618588')
+        self.assertTrue(validator.validate())
+
     def test_cy(self):
         validator = Validator('CY00532445O') # the last char is O from oranges
         self.assertTrue(validator.validate())
@@ -116,16 +138,24 @@ class TestValidator(unittest.TestCase):
         validator = Validator('CZ7103192744')
         self.assertFalse(validator.validate())
 
+        validator = Validator('CZ26159708')
+        self.assertTrue(validator.validate())
+
     def test_de(self):
         validator = Validator('DE111111125')
         self.assertTrue(validator.validate())
         self.assertEqual(validator.country_code, 'DE')
         self.assertEqual(validator.vat_number, '111111125')
+        validator = Validator('DE124718735')
+        self.assertTrue(validator.validate())
+        validator = Validator('DE180295363')
+        self.assertTrue(validator.validate())
+        validator = Validator('DE123475223')
+        self.assertTrue(validator.validate())
 
         validator = Validator('DE111111122')
         self.assertFalse(validator.validate())
 
-
     def test_dk(self):
         validator = Validator('DK88146328')
         self.assertTrue(validator.validate())
@@ -155,6 +185,39 @@ class TestValidator(unittest.TestCase):
         validator = Validator('EL040127798')
         self.assertFalse(validator.validate())
 
+        validator = Validator('EL999863881')
+        self.assertTrue(validator.validate())
+
+    def test_es(self):
+        # Juridical entities other than national ones
+        validator = Validator('esa0011012B')
+        self.assertTrue(validator.validate())
+        self.assertEqual(validator.country_code, 'ES')
+        self.assertEqual(validator.vat_number, 'A0011012B')
+        validator = Validator('ESA0011012B')
+        self.assertTrue(validator.validate())
+        self.assertEqual(validator.country_code, 'ES')
+        self.assertEqual(validator.vat_number, 'A0011012B')
+        validator = Validator('ESA0011012B', 'ES')
+        self.assertTrue(validator.validate())
+
+        validator = Validator('ESA0011011B')
+        self.assertFalse(validator.validate())
+
+        # Physical persons
+        validator = Validator('ESZ3964521D')
+        self.assertTrue(validator.validate())
+        validator = Validator('ESM3964521F')
+        self.assertTrue(validator.validate())
+
+        # National juridical entities
+        validator = Validator('ESB84968312')
+        self.assertTrue(validator.validate())
+        validator = Validator('ESB50860162')
+        self.assertTrue(validator.validate())
+        validator = Validator('ESB30034573')
+        self.assertTrue(validator.validate())
+
 if __name__ == '__main__':
     unittest.main()