1 # -*- coding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). All Rights Reserved
6 # Copyright (C) 2008-2009 B2CK, Cedric Krier, Bertrand Chenal (the methods "check_vat_[a-z]{2}"
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 ##############################################################################
24 from osv import osv, fields
25 from tools.translate import _
28 'be': 'BE0477472701', 'at': 'ATU12345675',
29 'bg': 'BG1234567892', 'cy': 'CY12345678F',
30 'cz': 'CZ12345679', 'de': 'DE123456788',
31 'dk': 'DK12345674', 'ee': 'EE123456780',
32 'es': 'ESA12345674', 'fi': 'FI12345671',
33 'fr': 'FR32123456789', 'gb': 'GB123456782',
34 'gr': 'GR12345670', 'hu': 'HU12345676',
35 'ie': 'IE1234567T', 'it': 'IT12345670017',
36 'lt': 'LT123456715', 'lu': 'LU12345613',
37 'lv': 'LV41234567891', 'mt': 'MT12345634',
38 'nl': 'NL123456782B90', 'pl': 'PL1234567883',
39 'pt': 'PT123456789', 'ro': 'RO1234567897',
40 'se': 'SE123456789701', 'si': 'SI12345679',
41 'sk': 'SK0012345675', 'el': 'EL12345670',
42 'mx': 'MXABC123456T1B'
47 """Sum each digits of the multiplication of i and j."""
48 return reduce(lambda x, y: x + int(y), str(i*j), 0)
50 class res_partner(osv.osv):
51 _inherit = 'res.partner'
53 def _split_vat(self, vat):
54 vat_country, vat_number = vat[:2].lower(), vat[2:].replace(' ', '')
55 return vat_country, vat_number
57 def check_vat(self, cr, uid, ids, context=None):
59 Check the VAT number depending of the country.
60 http://sima-pc.com/nif.php
62 country_obj = self.pool.get('res.country')
63 for partner in self.browse(cr, uid, ids, context=context):
66 vat_country, vat_number = self._split_vat(partner.vat)
67 if not hasattr(self, 'check_vat_' + vat_country):
68 if country_obj.search(cr, uid, [('code', 'ilike', vat_country)], context=context):
71 check = getattr(self, 'check_vat_' + vat_country)
72 if not check(vat_number):
76 def vat_change(self, cr, uid, ids, value, context=None):
77 return {'value': {'vat_subjected': bool(value)}}
80 'vat_subjected': fields.boolean('VAT Legal Statement', help="Check this box if the partner is subjected to the VAT. It will be used for the VAT legal statement.")
83 def _construct_constraint_msg(self, cr, uid, ids, context=None):
84 def default_vat_check(cn, vn):
85 # by default, a VAT number is valid if:
86 # it starts with 2 letters
87 # has more than 3 characters
88 return cn[0] in string.ascii_lowercase and cn[1] in string.ascii_lowercase
89 vat_country, vat_number = self._split_vat(self.browse(cr, uid, ids)[0].vat)
90 if default_vat_check(vat_country, vat_number):
91 vat_no = vat_country in _ref_vat and _ref_vat[vat_country] or 'Country Code + Vat Number'
92 return _('The Vat does not seems to be correct. You should have entered something like this %s'), (vat_no)
93 return _('The VAT is invalid, It should begin with the country code'), ()
95 _constraints = [(check_vat, _construct_constraint_msg, ["vat"])]
97 # code from the following methods come from Tryton (B2CK)
98 # http://www.tryton.org/hgwebdir.cgi/modules/relationship/file/544d1de586d9/party.py
99 def check_vat_at(self, vat):
101 Check Austria VAT number.
112 sum = int(num[0]) + mult_add(2, int(num[1])) + \
113 int(num[2]) + mult_add(2, int(num[3])) + \
114 int(num[4]) + mult_add(2, int(num[5])) + \
116 check = 10 - ((sum + 4) % 10)
119 if int(vat[-1:]) != check:
123 def check_vat_be(self, vat):
125 Check Belgium VAT number.
133 if int(vat[-2:]) != \
134 97 - (int(vat[:8]) % 97):
138 def check_vat_bg(self, vat):
140 Check Bulgaria VAT number.
142 if len(vat) not in [9,10]:
148 if int(vat[0]) in (2, 3) and \
151 sum = 4 * int(vat[0]) + 3 * int(vat[1]) + 2 * int(vat[2]) + \
152 7 * int(vat[3]) + 6 * int(vat[4]) + 5 * int(vat[5]) + \
153 4 * int(vat[6]) + 3 * int(vat[7]) + 2 * int(vat[8])
154 check = 11 - (sum % 11)
159 def check_vat_cy(self, vat):
161 Check Cyprus VAT number.
205 sum = n0 + n1 + n2 + n3 + n4 + n5 + n6 + n7
206 check = chr(sum % 26 + 65)
211 def check_vat_cz(self, vat):
213 Check Czech Republic VAT number.
215 if len(vat) not in (8, 9, 10):
223 if int(vat[0]) not in (0, 1, 2, 3, 4, 5, 6, 7, 8):
225 sum = 8 * int(vat[0]) + 7 * int(vat[1]) + 6 * int(vat[2]) + \
226 5 * int(vat[3]) + 4 * int(vat[4]) + 3 * int(vat[5]) + \
228 check = 11 - (sum % 11)
233 if check != int(vat[7]):
235 elif len(vat) == 9 and int(vat[0]) == 6:
236 sum = 8 * int(vat[1]) + 7 * int(vat[2]) + 6 * int(vat[3]) + \
237 5 * int(vat[4]) + 4 * int(vat[5]) + 3 * int(vat[6]) + \
239 check = 9 - ((11 - (sum % 11)) % 10)
240 if check != int(vat[8]):
243 if int(vat[0:2]) > 53 and int(vat[0:2]) < 80:
245 if int(vat[2:4]) < 1:
247 if int(vat[2:4]) > 12 and int(vat[2:4]) < 51:
249 if int(vat[2:4]) > 62:
251 if int(vat[2:4]) in (2, 52) and int(vat[0:2]) % 4 > 0:
252 if int(vat[4:6]) < 1:
254 if int(vat[4:6]) > 28:
256 if int(vat[2:4]) in (2, 52) and int(vat[0:2]) % 4 == 0:
257 if int(vat[4:6]) < 1:
259 if int(vat[4:6]) > 29:
261 if int(vat[2:4]) in (4, 6, 9, 11, 54, 56, 59, 61):
262 if int(vat[4:6]) < 1:
264 if int(vat[4:6]) > 30:
266 if int(vat[2:4]) in (1, 3, 5, 7, 8, 10, 12, 51,
267 53, 55, 57, 58, 60, 62):
268 if int(vat[4:6]) < 1:
270 if int(vat[4:6]) > 31:
273 if int(vat[0:2]) < 54:
275 if int(vat[2:4]) < 1:
277 if int(vat[2:4]) > 12 and int(vat[2:4]) < 51:
279 if int(vat[2:4]) > 62:
281 if int(vat[2:4]) in (2, 52) and int(vat[0:2]) % 4 > 0:
282 if int(vat[4:6]) < 1:
284 if int(vat[4:6]) > 28:
286 if int(vat[2:4]) in (2, 52) and int(vat[0:2]) % 4 == 0:
287 if int(vat[4:6]) < 1:
289 if int(vat[4:6]) > 29:
291 if int(vat[2:4]) in (4, 6, 9, 11, 54, 56, 59, 61):
292 if int(vat[4:6]) < 1:
294 if int(vat[4:6]) > 30:
296 if int(vat[2:4]) in (1, 3, 5, 7, 8, 10, 12, 51,
297 53, 55, 57, 58, 60, 62):
298 if int(vat[4:6]) < 1:
300 if int(vat[4:6]) > 31:
302 if (int(vat[0:2]) + int(vat[2:4]) + int(vat[4:6]) + int(vat[6:8]) +
303 int(vat[8:10])) % 11 != 0:
305 if int(vat[0:10]) % 11 != 0:
309 def check_vat_de(self, vat):
311 Check Germany VAT number.
319 if int(vat[0:7]) <= 0:
323 sum = (2 * ((int(vat[i]) + sum + 9) % 10 + 1)) % 11
327 if int(vat[8]) != check:
331 def check_vat_dk(self, vat):
333 Check Denmark VAT number.
343 sum = 2 * int(vat[0]) + 7 * int(vat[1]) + 6 * int(vat[2]) + \
344 5 * int(vat[3]) + 4 * int(vat[4]) + 3 * int(vat[5]) + \
345 2 * int(vat[6]) + int(vat[7])
350 def check_vat_ee(self, vat):
352 Check Estonia VAT number.
360 sum = 3 * int(vat[0]) + 7 * int(vat[1]) + 1 * int(vat[2]) + \
361 3 * int(vat[3]) + 7 * int(vat[4]) + 1 * int(vat[5]) + \
362 3 * int(vat[6]) + 7 * int(vat[7])
363 check = 10 - (sum % 10)
366 if check != int(vat[8]):
370 def check_vat_es(self, vat):
372 Check Spain VAT number.
402 #Legal persons with profit aim
403 if vat[0] in ('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'U', 'V'):
408 sum = mult_add(2, int(vat[1])) + int(vat[2]) + \
409 mult_add(2, int(vat[3])) + int(vat[4]) + \
410 mult_add(2, int(vat[5])) + int(vat[6]) + \
411 mult_add(2, int(vat[7]))
412 check = 10 - (sum % 10)
416 #Legal persons with non-profit aim
417 elif vat[0] in ('N', 'P', 'Q', 'R', 'S', 'W'):
422 sum = mult_add(2, int(vat[1])) + int(vat[2]) + \
423 mult_add(2, int(vat[3])) + int(vat[4]) + \
424 mult_add(2, int(vat[5])) + int(vat[6]) + \
425 mult_add(2, int(vat[7]))
426 check = 10 - (sum % 10)
427 check = chr(check + 64)
431 #Foreign natural persons, under age 14 or non-residents
432 elif vat[0] in ('K', 'L', 'M', 'X', 'Y', 'Z'):
434 check_value = '1' + vat[1:8]
436 check_value = '2' + vat[1:8]
438 check_value = vat[1:8]
444 check = 1 + (int(check_value) % 23)
450 #Spanish natural persons
456 check = 1 + (int(vat[:8]) % 23)
463 def check_vat_fi(self, vat):
465 Check Finland VAT number.
473 sum = 7 * int(vat[0]) + 9 * int(vat[1]) + 10 * int(vat[2]) + \
474 5 * int(vat[3]) + 8 * int(vat[4]) + 4 * int(vat[5]) + \
476 check = 11 - (sum % 11)
481 if check != int(vat[7]):
485 def check_vat_fr(self, vat):
487 Check France VAT number.
505 check = ((int(vat[2:11]) * 100) + 12) % 97
506 if check != int(vat[0:2]):
510 conv = ['0', '1', '2', '3', '4', '5', '6', '7',
511 '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
512 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T',
513 'U', 'V', 'W', 'X', 'Y', 'Z']
514 if vat[0] not in conv \
515 or vat[1] not in conv:
517 c1 = conv.index(vat[0])
518 c2 = conv.index(vat[1])
521 sum = c1 * 24 + c2 - 10
523 sum = c1 * 34 + c2 - 100
526 sum = (int(sum) / 11) + 1
527 y = (int(vat[2:11]) + sum) % 11
532 def check_vat_gb(self, vat):
534 Check United Kingdom VAT number.
544 if int(vat[2:5]) >= 500:
548 if int(vat[2:5]) < 500:
552 elif len(vat) in (9, 10):
558 if int(vat[0:7]) < 1:
560 if int(vat[0:7]) > 19999 and int(vat[0:7]) < 1000000:
562 if int(vat[7:9]) > 97:
564 if len(vat) == 10 and int(vat[9]) != 3:
567 sum = 8 * int(vat[0]) + 7 * int(vat[1]) + 6 * int(vat[2]) + \
568 5 * int(vat[3]) + 4 * int(vat[4]) + 3 * int(vat[5]) + \
569 2 * int(vat[6]) + 10 * int(vat[7]) + int(vat[8])
570 if int(vat[0:3]) > 100:
571 if sum % 97 not in (0, 55, 42):
577 elif len(vat) in (12, 13):
583 if int(vat[0:3]) not in (0, 1):
586 if int(vat[3:10]) < 1:
588 if int(vat[3:10]) > 19999 and int(vat[3:10]) < 1000000:
590 if int(vat[10:12]) > 97:
592 if len(vat) == 13 and int(vat[12]) != 3:
595 sum = 8 * int(vat[3]) + 7 * int(vat[4]) + 6 * int(vat[5]) + \
596 5 * int(vat[6]) + 4 * int(vat[7]) + 3 * int(vat[8]) + \
597 2 * int(vat[9]) + 10 * int(vat[10]) + int(vat[11])
603 def check_vat_gr(self, vat):
605 Check Greece VAT number.
612 sum = 128 * int(vat[0]) + 64 * int(vat[1]) + 32 * int(vat[2]) + \
613 16 * int(vat[3]) + 8 * int(vat[4]) + 4 * int(vat[5]) + \
618 if check != int(vat[7]):
622 sum = 256 * int(vat[0]) + 128 * int(vat[1]) + 64 * int(vat[2]) + \
623 32 * int(vat[3]) + 16 * int(vat[4]) + 8 * int(vat[5]) + \
624 4 * int(vat[6]) + 2 * int(vat[7])
628 if check != int(vat[8]):
633 def check_vat_el(self, vat):
634 return self.check_vat_gr(vat)
636 def check_vat_hu(self, vat):
638 Check Hungary VAT number.
648 sum = 9 * int(vat[0]) + 7 * int(vat[1]) + 3 * int(vat[2]) + \
649 1 * int(vat[3]) + 9 * int(vat[4]) + 7 * int(vat[5]) + \
651 check = 10 - (sum % 10)
654 if check != int(vat[7]):
658 def check_vat_ie(self, vat):
660 Check Ireland VAT number.
664 if (ord(vat[1]) >= 65 and ord(vat[1]) <= 90) \
665 or vat[1] in ('+', '*'):
675 sum = 7 * int(vat[2]) + 6 * int(vat[3]) + 5 * int(vat[4]) + \
676 4 * int(vat[5]) + 3 * int(vat[6]) + 2 * int(vat[0])
681 check = chr(check + 64)
691 sum = 8 * int(vat[0]) + 7 * int(vat[1]) + 6 * int(vat[2]) + \
692 5 * int(vat[3]) + 4 * int(vat[4]) + 3 * int(vat[5]) + \
698 check = chr(check + 64)
703 def check_vat_it(self, vat):
705 Check Italy VAT number.
713 if int(vat[0:7]) <= 0:
715 if int(vat[7:10]) <= 0:
717 if int(vat[7:10]) > 100 and int(vat[7:10]) < 120:
720 sum = int(vat[0]) + mult_add(2, int(vat[1])) + int(vat[2]) + \
721 mult_add(2, int(vat[3])) + int(vat[4]) + \
722 mult_add(2, int(vat[5])) + int(vat[6]) + \
723 mult_add(2, int(vat[7])) + int(vat[8]) + \
724 mult_add(2, int(vat[9]))
725 check = 10 - (sum % 10)
728 if check != int(vat[10]):
732 def check_vat_lt(self, vat):
734 Check Lithuania VAT number.
744 sum = 1 * int(vat[0]) + 2 * int(vat[1]) + 3 * int(vat[2]) + \
745 4 * int(vat[3]) + 5 * int(vat[4]) + 6 * int(vat[5]) + \
746 7 * int(vat[6]) + 8 * int(vat[7])
748 sum = 3 * int(vat[0]) + 4 * int(vat[1]) + 5 * int(vat[2]) + \
749 6 * int(vat[3]) + 7 * int(vat[4]) + 8 * int(vat[5]) + \
750 9 * int(vat[6]) + 1 * int(vat[7])
754 if check != int(vat[8]):
758 if int(vat[10]) != 1:
760 sum = 1 * int(vat[0]) + 2 * int(vat[1]) + 3 * int(vat[2]) + \
761 4 * int(vat[3]) + 5 * int(vat[4]) + 6 * int(vat[5]) + \
762 7 * int(vat[6]) + 8 * int(vat[7]) + 9 * int(vat[8]) + \
763 1 * int(vat[9]) + 2 * int(vat[10])
765 sum = 3 * int(vat[0]) + 4 * int(vat[1]) + 5 * int(vat[2]) + \
766 6 * int(vat[3]) + 7 * int(vat[4]) + 8 * int(vat[5]) + \
767 9 * int(vat[6]) + 1 * int(vat[7]) + 2 * int(vat[8]) + \
768 3 * int(vat[9]) + 4 * int(vat[10])
772 if check != int(vat[11]):
777 def check_vat_lu(self, vat):
779 Check Luxembourg VAT number.
787 if int(vat[0:6]) <= 0:
789 check = int(vat[0:6]) % 89
790 if check != int(vat[6:8]):
794 def check_vat_lv(self, vat):
796 Check Latvia VAT number.
805 sum = 9 * int(vat[0]) + 1 * int(vat[1]) + 4 * int(vat[2]) + \
806 8 * int(vat[3]) + 3 * int(vat[4]) + 10 * int(vat[5]) + \
807 2 * int(vat[6]) + 5 * int(vat[7]) + 7 * int(vat[8]) + \
809 if sum % 11 == 4 and int(vat[0]) == 9:
812 check = 4 - (sum % 11)
814 check = 14 - (sum % 11)
816 check = 3 - (sum % 11)
817 if check != int(vat[10]):
821 if int(vat[2:4]) == 2 and int(vat[4:6]) % 4 > 0:
822 if int(vat[0:2]) < 1 or int(vat[0:2]) > 28:
824 if int(vat[2:4]) == 2 and int(vat[4:6]) % 4 == 0:
825 if int(vat[0:2]) < 1 or int(vat[0:2]) > 29:
827 if int(vat[2:4]) in (4, 6, 9, 11):
828 if int(vat[0:2]) < 1 or int(vat[0:2]) > 30:
830 if int(vat[2:4]) in (1, 3, 5, 7, 8, 10, 12):
831 if int(vat[0:2]) < 1 or int(vat[0:2]) > 31:
833 if int(vat[2:4]) < 1 or int(vat[2:4]) > 12:
837 def check_vat_mt(self, vat):
839 Check Malta VAT number.
848 if int(vat[0:6]) < 100000:
851 sum = 3 * int(vat[0]) + 4 * int(vat[1]) + 6 * int(vat[2]) + \
852 7 * int(vat[3]) + 8 * int(vat[4]) + 9 * int(vat[5])
853 check = 37 - (sum % 37)
854 if check != int(vat[6:8]):
858 def check_vat_nl(self, vat):
860 Check Netherlands VAT number.
869 if int(vat[0:8]) <= 0:
874 sum = 9 * int(vat[0]) + 8 * int(vat[1]) + 7 * int(vat[2]) + \
875 6 * int(vat[3]) + 5 * int(vat[4]) + 4 * int(vat[5]) + \
876 3 * int(vat[6]) + 2 * int(vat[7])
881 if check != int(vat[8]):
885 def check_vat_pl(self, vat):
887 Check Poland VAT number.
896 sum = 6 * int(vat[0]) + 5 * int(vat[1]) + 7 * int(vat[2]) + \
897 2 * int(vat[3]) + 3 * int(vat[4]) + 4 * int(vat[5]) + \
898 5 * int(vat[6]) + 6 * int(vat[7]) + 7 * int(vat[8])
902 if check != int(vat[9]):
906 def check_vat_pt(self, vat):
908 Check Portugal VAT number.
920 sum = 9 * int(vat[0]) + 8 * int(vat[1]) + 7 * int(vat[2]) + \
921 6 * int(vat[3]) + 5 * int(vat[4]) + 4 * int(vat[5]) + \
922 3 * int(vat[6]) + 2 * int(vat[7])
923 check = 11 - (sum % 11)
924 if check == 10 or check == 11:
928 def check_vat_ro(self, vat):
930 Check Romania VAT number.
937 if len(vat) >= 2 and len(vat) <= 10:
938 vat = (10 - len(vat)) * '0' + vat
939 sum = 7 * int(vat[0]) + 5 * int(vat[1]) + 3 * int(vat[2]) + \
940 2 * int(vat[3]) + 1 * int(vat[4]) + 7 * int(vat[5]) + \
941 5 * int(vat[6]) + 3 * int(vat[7]) + 2 * int(vat[8])
942 check = (sum * 10) % 11
945 if check != int(vat[9]):
949 if int(vat[0]) not in (1, 2, 3, 4, 6):
951 if int(vat[3:5]) < 1 or int(vat[3:5]) > 12:
953 if int(vat[3:5]) == 2 and int(vat[1:3]) % 4 > 0:
954 if int(vat[5:7]) < 1 or int(vat[5:7]) > 28:
956 if int(vat[3:5]) == 2 and int(vat[1:3]) % 4 == 0:
957 if int(vat[5:7]) < 1 or int(vat[5:7]) > 29:
959 if int(vat[3:5]) in (4, 6, 9, 11):
960 if int(vat[5:7]) < 1 or int(vat[5:7]) > 30:
962 if int(vat[3:5]) in (1, 3, 5, 7, 8, 10, 12):
963 if int(vat[5:7]) < 1 or int(vat[5:7]) > 31:
966 sum = 2 * int(vat[0]) + 7 * int(vat[1]) + 9 * int(vat[2]) + \
967 1 * int(vat[3]) + 4 * int(vat[4]) + 6 * int(vat[5]) + \
968 3 * int(vat[6]) + 5 * int(vat[7]) + 8 * int(vat[8]) + \
969 2 * int(vat[9]) + 7 * int(vat[10]) + 9 * int(vat[11])
973 if check != int(vat[12]):
978 def check_vat_se(self, vat):
980 Check Sweden VAT number.
989 if int(vat[9:11]) < 0:
992 sum = mult_add(2, int(vat[0])) + int(vat[1]) + \
993 mult_add(2, int(vat[2])) + int(vat[3]) + \
994 mult_add(2, int(vat[4])) + int(vat[5]) + \
995 mult_add(2, int(vat[6])) + int(vat[7]) + \
996 mult_add(2, int(vat[8]))
997 check = 10 - (sum % 10)
1000 if check != int(vat[9]):
1004 def check_vat_si(self, vat):
1006 Check Slovenia VAT number.
1014 if int(vat[0:7]) <= 999999:
1017 sum = 8 * int(vat[0]) + 7 * int(vat[1]) + 6 * int(vat[2]) + \
1018 5 * int(vat[3]) + 4 * int(vat[4]) + 3 * int(vat[5]) + \
1020 check = 11 - (sum % 11)
1025 if check != int(vat[7]):
1029 def check_vat_sk(self, vat):
1031 Check Slovakia VAT number.
1037 if len(vat) not in(9, 10):
1040 if int(vat[0:2]) in (0, 10, 20) and len(vat) == 10:
1044 if int(vat[0:2]) < 54 or int(vat[0:2]) > 99:
1048 if int(vat[0:2]) > 53 :
1051 if int(vat[2:4]) < 1:
1053 if int(vat[2:4]) > 12 and int(vat[2:4]) < 51:
1055 if int(vat[2:4]) > 62:
1057 if int(vat[2:4]) in (2, 52) and int(vat[0:2]) % 4 > 0:
1058 if int(vat[4:6]) < 1 or int(vat[4:6]) > 28:
1060 if int(vat[2:4]) in (2, 52) and int(vat[0:2]) % 4 == 0:
1061 if int(vat[4:6]) < 1 or int(vat[4:6]) > 29:
1063 if int(vat[2:4]) in (4, 6, 9, 11, 54, 56, 59, 61):
1064 if int(vat[4:6]) < 1 or int(vat[4:6]) > 30:
1066 if int(vat[2:4]) in (1, 3, 5, 7, 8, 10, 12,
1067 51, 53, 55, 57, 58, 60, 62):
1068 if int(vat[4:6]) < 1 or int(vat[4:6]) > 31:
1072 def check_vat_mx(self, vat):
1074 Verificar RFC méxico
1076 if not 12 <= len(vat) <= 13:
1078 elif len(vat)==12 and not vat[:3].isalpha() | vat[3:9].isdigit() | vat[-3:].isalnum():
1080 elif len(vat)==13 and not vat[:4].isalpha() | vat[4:10].isdigit() | vat[-3:].isalnum():
1085 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: