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 for partner in self.browse(cr, uid, ids, context=context):
65 vat_country, vat_number = self._split_vat(partner.vat)
66 if not hasattr(self, 'check_vat_' + vat_country):
67 country_code = vat_country.upper()
68 code = self.pool.get('res.country').search(cr, uid, [('code', '=', country_code)])
72 check = getattr(self, 'check_vat_' + vat_country)
73 if not check(vat_number):
77 def vat_change(self, cr, uid, ids, value, context=None):
78 return {'value': {'vat_subjected': bool(value)}}
81 '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.")
84 def _construct_constraint_msg(self, cr, uid, ids, context=None):
85 def default_vat_check(cn, vn):
86 # by default, a VAT number is valid if:
87 # it starts with 2 letters
88 # has more than 3 characters
89 return cn[0] in string.ascii_lowercase and cn[1] in string.ascii_lowercase
90 vat_country, vat_number = self._split_vat(self.browse(cr, uid, ids)[0].vat)
91 if default_vat_check(vat_country, vat_number):
92 vat_no = vat_country in _ref_vat and _ref_vat[vat_country] or 'Country Code + Vat Number'
93 return _('The Vat does not seems to be correct. You should have entered something like this %s'), (vat_no)
94 return _('The VAT is invalid, It should begin with the country code'), ()
96 _constraints = [(check_vat, _construct_constraint_msg, ["vat"])]
98 # code from the following methods come from Tryton (B2CK)
99 # http://www.tryton.org/hgwebdir.cgi/modules/relationship/file/544d1de586d9/party.py
100 def check_vat_at(self, vat):
102 Check Austria VAT number.
113 sum = int(num[0]) + mult_add(2, int(num[1])) + \
114 int(num[2]) + mult_add(2, int(num[3])) + \
115 int(num[4]) + mult_add(2, int(num[5])) + \
117 check = 10 - ((sum + 4) % 10)
120 if int(vat[-1:]) != check:
124 def check_vat_be(self, vat):
126 Check Belgium VAT number.
134 if int(vat[-2:]) != \
135 97 - (int(vat[:8]) % 97):
139 def check_vat_bg(self, vat):
141 Check Bulgaria VAT number.
143 if len(vat) not in [9,10]:
149 if int(vat[0]) in (2, 3) and \
152 sum = 4 * int(vat[0]) + 3 * int(vat[1]) + 2 * int(vat[2]) + \
153 7 * int(vat[3]) + 6 * int(vat[4]) + 5 * int(vat[5]) + \
154 4 * int(vat[6]) + 3 * int(vat[7]) + 2 * int(vat[8])
155 check = 11 - (sum % 11)
160 def check_vat_cy(self, vat):
162 Check Cyprus VAT number.
206 sum = n0 + n1 + n2 + n3 + n4 + n5 + n6 + n7
207 check = chr(sum % 26 + 65)
212 def check_vat_cz(self, vat):
214 Check Czech Republic VAT number.
216 if len(vat) not in (8, 9, 10):
224 if int(vat[0]) not in (0, 1, 2, 3, 4, 5, 6, 7, 8):
226 sum = 8 * int(vat[0]) + 7 * int(vat[1]) + 6 * int(vat[2]) + \
227 5 * int(vat[3]) + 4 * int(vat[4]) + 3 * int(vat[5]) + \
229 check = 11 - (sum % 11)
234 if check != int(vat[7]):
236 elif len(vat) == 9 and int(vat[0]) == 6:
237 sum = 8 * int(vat[1]) + 7 * int(vat[2]) + 6 * int(vat[3]) + \
238 5 * int(vat[4]) + 4 * int(vat[5]) + 3 * int(vat[6]) + \
240 check = 9 - ((11 - (sum % 11)) % 10)
241 if check != int(vat[8]):
244 if int(vat[0:2]) > 53 and int(vat[0:2]) < 80:
246 if int(vat[2:4]) < 1:
248 if int(vat[2:4]) > 12 and int(vat[2:4]) < 51:
250 if int(vat[2:4]) > 62:
252 if int(vat[2:4]) in (2, 52) and int(vat[0:2]) % 4 > 0:
253 if int(vat[4:6]) < 1:
255 if int(vat[4:6]) > 28:
257 if int(vat[2:4]) in (2, 52) and int(vat[0:2]) % 4 == 0:
258 if int(vat[4:6]) < 1:
260 if int(vat[4:6]) > 29:
262 if int(vat[2:4]) in (4, 6, 9, 11, 54, 56, 59, 61):
263 if int(vat[4:6]) < 1:
265 if int(vat[4:6]) > 30:
267 if int(vat[2:4]) in (1, 3, 5, 7, 8, 10, 12, 51,
268 53, 55, 57, 58, 60, 62):
269 if int(vat[4:6]) < 1:
271 if int(vat[4:6]) > 31:
274 if int(vat[0:2]) < 54:
276 if int(vat[2:4]) < 1:
278 if int(vat[2:4]) > 12 and int(vat[2:4]) < 51:
280 if int(vat[2:4]) > 62:
282 if int(vat[2:4]) in (2, 52) and int(vat[0:2]) % 4 > 0:
283 if int(vat[4:6]) < 1:
285 if int(vat[4:6]) > 28:
287 if int(vat[2:4]) in (2, 52) and int(vat[0:2]) % 4 == 0:
288 if int(vat[4:6]) < 1:
290 if int(vat[4:6]) > 29:
292 if int(vat[2:4]) in (4, 6, 9, 11, 54, 56, 59, 61):
293 if int(vat[4:6]) < 1:
295 if int(vat[4:6]) > 30:
297 if int(vat[2:4]) in (1, 3, 5, 7, 8, 10, 12, 51,
298 53, 55, 57, 58, 60, 62):
299 if int(vat[4:6]) < 1:
301 if int(vat[4:6]) > 31:
303 if (int(vat[0:2]) + int(vat[2:4]) + int(vat[4:6]) + int(vat[6:8]) +
304 int(vat[8:10])) % 11 != 0:
306 if int(vat[0:10]) % 11 != 0:
310 def check_vat_de(self, vat):
312 Check Germany VAT number.
320 if int(vat[0:7]) <= 0:
324 sum = (2 * ((int(vat[i]) + sum + 9) % 10 + 1)) % 11
328 if int(vat[8]) != check:
332 def check_vat_dk(self, vat):
334 Check Denmark VAT number.
344 sum = 2 * int(vat[0]) + 7 * int(vat[1]) + 6 * int(vat[2]) + \
345 5 * int(vat[3]) + 4 * int(vat[4]) + 3 * int(vat[5]) + \
346 2 * int(vat[6]) + int(vat[7])
351 def check_vat_ee(self, vat):
353 Check Estonia VAT number.
361 sum = 3 * int(vat[0]) + 7 * int(vat[1]) + 1 * int(vat[2]) + \
362 3 * int(vat[3]) + 7 * int(vat[4]) + 1 * int(vat[5]) + \
363 3 * int(vat[6]) + 7 * int(vat[7])
364 check = 10 - (sum % 10)
367 if check != int(vat[8]):
371 def check_vat_es(self, vat):
373 Check Spain VAT number.
403 #Legal persons with profit aim
404 if vat[0] in ('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'U', 'V'):
409 sum = mult_add(2, int(vat[1])) + int(vat[2]) + \
410 mult_add(2, int(vat[3])) + int(vat[4]) + \
411 mult_add(2, int(vat[5])) + int(vat[6]) + \
412 mult_add(2, int(vat[7]))
413 check = 10 - (sum % 10)
417 #Legal persons with non-profit aim
418 elif vat[0] in ('N', 'P', 'Q', 'R', 'S', 'W'):
423 sum = mult_add(2, int(vat[1])) + int(vat[2]) + \
424 mult_add(2, int(vat[3])) + int(vat[4]) + \
425 mult_add(2, int(vat[5])) + int(vat[6]) + \
426 mult_add(2, int(vat[7]))
427 check = 10 - (sum % 10)
428 check = chr(check + 64)
432 #Foreign natural persons, under age 14 or non-residents
433 elif vat[0] in ('K', 'L', 'M', 'X', 'Y', 'Z'):
435 check_value = '1' + vat[1:8]
437 check_value = '2' + vat[1:8]
439 check_value = vat[1:8]
445 check = 1 + (int(check_value) % 23)
451 #Spanish natural persons
457 check = 1 + (int(vat[:8]) % 23)
464 def check_vat_fi(self, vat):
466 Check Finland VAT number.
474 sum = 7 * int(vat[0]) + 9 * int(vat[1]) + 10 * int(vat[2]) + \
475 5 * int(vat[3]) + 8 * int(vat[4]) + 4 * int(vat[5]) + \
477 check = 11 - (sum % 11)
482 if check != int(vat[7]):
486 def check_vat_fr(self, vat):
488 Check France VAT number.
506 check = ((int(vat[2:11]) * 100) + 12) % 97
507 if check != int(vat[0:2]):
511 conv = ['0', '1', '2', '3', '4', '5', '6', '7',
512 '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
513 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T',
514 'U', 'V', 'W', 'X', 'Y', 'Z']
515 if vat[0] not in conv \
516 or vat[1] not in conv:
518 c1 = conv.index(vat[0])
519 c2 = conv.index(vat[1])
522 sum = c1 * 24 + c2 - 10
524 sum = c1 * 34 + c2 - 100
527 sum = (int(sum) / 11) + 1
528 y = (int(vat[2:11]) + sum) % 11
533 def check_vat_gb(self, vat):
535 Check United Kingdom VAT number.
545 if int(vat[2:5]) >= 500:
549 if int(vat[2:5]) < 500:
553 elif len(vat) in (9, 10):
559 if int(vat[0:7]) < 1:
561 if int(vat[0:7]) > 19999 and int(vat[0:7]) < 1000000:
563 if int(vat[7:9]) > 97:
565 if len(vat) == 10 and int(vat[9]) != 3:
568 sum = 8 * int(vat[0]) + 7 * int(vat[1]) + 6 * int(vat[2]) + \
569 5 * int(vat[3]) + 4 * int(vat[4]) + 3 * int(vat[5]) + \
570 2 * int(vat[6]) + 10 * int(vat[7]) + int(vat[8])
571 if int(vat[0:3]) > 100:
572 if sum % 97 not in (0, 55, 42):
578 elif len(vat) in (12, 13):
584 if int(vat[0:3]) not in (0, 1):
587 if int(vat[3:10]) < 1:
589 if int(vat[3:10]) > 19999 and int(vat[3:10]) < 1000000:
591 if int(vat[10:12]) > 97:
593 if len(vat) == 13 and int(vat[12]) != 3:
596 sum = 8 * int(vat[3]) + 7 * int(vat[4]) + 6 * int(vat[5]) + \
597 5 * int(vat[6]) + 4 * int(vat[7]) + 3 * int(vat[8]) + \
598 2 * int(vat[9]) + 10 * int(vat[10]) + int(vat[11])
604 def check_vat_gr(self, vat):
606 Check Greece VAT number.
613 sum = 128 * int(vat[0]) + 64 * int(vat[1]) + 32 * int(vat[2]) + \
614 16 * int(vat[3]) + 8 * int(vat[4]) + 4 * int(vat[5]) + \
619 if check != int(vat[7]):
623 sum = 256 * int(vat[0]) + 128 * int(vat[1]) + 64 * int(vat[2]) + \
624 32 * int(vat[3]) + 16 * int(vat[4]) + 8 * int(vat[5]) + \
625 4 * int(vat[6]) + 2 * int(vat[7])
629 if check != int(vat[8]):
634 def check_vat_el(self, vat):
635 return self.check_vat_gr(vat)
637 def check_vat_hu(self, vat):
639 Check Hungary VAT number.
649 sum = 9 * int(vat[0]) + 7 * int(vat[1]) + 3 * int(vat[2]) + \
650 1 * int(vat[3]) + 9 * int(vat[4]) + 7 * int(vat[5]) + \
652 check = 10 - (sum % 10)
655 if check != int(vat[7]):
659 def check_vat_ie(self, vat):
661 Check Ireland VAT number.
665 if (ord(vat[1]) >= 65 and ord(vat[1]) <= 90) \
666 or vat[1] in ('+', '*'):
676 sum = 7 * int(vat[2]) + 6 * int(vat[3]) + 5 * int(vat[4]) + \
677 4 * int(vat[5]) + 3 * int(vat[6]) + 2 * int(vat[0])
682 check = chr(check + 64)
692 sum = 8 * int(vat[0]) + 7 * int(vat[1]) + 6 * int(vat[2]) + \
693 5 * int(vat[3]) + 4 * int(vat[4]) + 3 * int(vat[5]) + \
699 check = chr(check + 64)
704 def check_vat_it(self, vat):
706 Check Italy VAT number.
714 if int(vat[0:7]) <= 0:
716 if int(vat[7:10]) <= 0:
718 if int(vat[7:10]) > 100 and int(vat[7:10]) < 120:
721 sum = int(vat[0]) + mult_add(2, int(vat[1])) + int(vat[2]) + \
722 mult_add(2, int(vat[3])) + int(vat[4]) + \
723 mult_add(2, int(vat[5])) + int(vat[6]) + \
724 mult_add(2, int(vat[7])) + int(vat[8]) + \
725 mult_add(2, int(vat[9]))
726 check = 10 - (sum % 10)
729 if check != int(vat[10]):
733 def check_vat_lt(self, vat):
735 Check Lithuania VAT number.
745 sum = 1 * int(vat[0]) + 2 * int(vat[1]) + 3 * int(vat[2]) + \
746 4 * int(vat[3]) + 5 * int(vat[4]) + 6 * int(vat[5]) + \
747 7 * int(vat[6]) + 8 * int(vat[7])
749 sum = 3 * int(vat[0]) + 4 * int(vat[1]) + 5 * int(vat[2]) + \
750 6 * int(vat[3]) + 7 * int(vat[4]) + 8 * int(vat[5]) + \
751 9 * int(vat[6]) + 1 * int(vat[7])
755 if check != int(vat[8]):
759 if int(vat[10]) != 1:
761 sum = 1 * int(vat[0]) + 2 * int(vat[1]) + 3 * int(vat[2]) + \
762 4 * int(vat[3]) + 5 * int(vat[4]) + 6 * int(vat[5]) + \
763 7 * int(vat[6]) + 8 * int(vat[7]) + 9 * int(vat[8]) + \
764 1 * int(vat[9]) + 2 * int(vat[10])
766 sum = 3 * int(vat[0]) + 4 * int(vat[1]) + 5 * int(vat[2]) + \
767 6 * int(vat[3]) + 7 * int(vat[4]) + 8 * int(vat[5]) + \
768 9 * int(vat[6]) + 1 * int(vat[7]) + 2 * int(vat[8]) + \
769 3 * int(vat[9]) + 4 * int(vat[10])
773 if check != int(vat[11]):
778 def check_vat_lu(self, vat):
780 Check Luxembourg VAT number.
788 if int(vat[0:6]) <= 0:
790 check = int(vat[0:6]) % 89
791 if check != int(vat[6:8]):
795 def check_vat_lv(self, vat):
797 Check Latvia VAT number.
806 sum = 9 * int(vat[0]) + 1 * int(vat[1]) + 4 * int(vat[2]) + \
807 8 * int(vat[3]) + 3 * int(vat[4]) + 10 * int(vat[5]) + \
808 2 * int(vat[6]) + 5 * int(vat[7]) + 7 * int(vat[8]) + \
810 if sum % 11 == 4 and int(vat[0]) == 9:
813 check = 4 - (sum % 11)
815 check = 14 - (sum % 11)
817 check = 3 - (sum % 11)
818 if check != int(vat[10]):
822 if int(vat[2:4]) == 2 and int(vat[4:6]) % 4 > 0:
823 if int(vat[0:2]) < 1 or int(vat[0:2]) > 28:
825 if int(vat[2:4]) == 2 and int(vat[4:6]) % 4 == 0:
826 if int(vat[0:2]) < 1 or int(vat[0:2]) > 29:
828 if int(vat[2:4]) in (4, 6, 9, 11):
829 if int(vat[0:2]) < 1 or int(vat[0:2]) > 30:
831 if int(vat[2:4]) in (1, 3, 5, 7, 8, 10, 12):
832 if int(vat[0:2]) < 1 or int(vat[0:2]) > 31:
834 if int(vat[2:4]) < 1 or int(vat[2:4]) > 12:
838 def check_vat_mt(self, vat):
840 Check Malta VAT number.
849 if int(vat[0:6]) < 100000:
852 sum = 3 * int(vat[0]) + 4 * int(vat[1]) + 6 * int(vat[2]) + \
853 7 * int(vat[3]) + 8 * int(vat[4]) + 9 * int(vat[5])
854 check = 37 - (sum % 37)
855 if check != int(vat[6:8]):
859 def check_vat_nl(self, vat):
861 Check Netherlands VAT number.
870 if int(vat[0:8]) <= 0:
875 sum = 9 * int(vat[0]) + 8 * int(vat[1]) + 7 * int(vat[2]) + \
876 6 * int(vat[3]) + 5 * int(vat[4]) + 4 * int(vat[5]) + \
877 3 * int(vat[6]) + 2 * int(vat[7])
882 if check != int(vat[8]):
886 def check_vat_pl(self, vat):
888 Check Poland VAT number.
897 sum = 6 * int(vat[0]) + 5 * int(vat[1]) + 7 * int(vat[2]) + \
898 2 * int(vat[3]) + 3 * int(vat[4]) + 4 * int(vat[5]) + \
899 5 * int(vat[6]) + 6 * int(vat[7]) + 7 * int(vat[8])
903 if check != int(vat[9]):
907 def check_vat_pt(self, vat):
909 Check Portugal VAT number.
921 sum = 9 * int(vat[0]) + 8 * int(vat[1]) + 7 * int(vat[2]) + \
922 6 * int(vat[3]) + 5 * int(vat[4]) + 4 * int(vat[5]) + \
923 3 * int(vat[6]) + 2 * int(vat[7])
924 check = 11 - (sum % 11)
925 if check == 10 or check == 11:
929 def check_vat_ro(self, vat):
931 Check Romania VAT number.
938 if len(vat) >= 2 and len(vat) <= 10:
939 vat = (10 - len(vat)) * '0' + vat
940 sum = 7 * int(vat[0]) + 5 * int(vat[1]) + 3 * int(vat[2]) + \
941 2 * int(vat[3]) + 1 * int(vat[4]) + 7 * int(vat[5]) + \
942 5 * int(vat[6]) + 3 * int(vat[7]) + 2 * int(vat[8])
943 check = (sum * 10) % 11
946 if check != int(vat[9]):
950 if int(vat[0]) not in (1, 2, 3, 4, 6):
952 if int(vat[3:5]) < 1 or int(vat[3:5]) > 12:
954 if int(vat[3:5]) == 2 and int(vat[1:3]) % 4 > 0:
955 if int(vat[5:7]) < 1 or int(vat[5:7]) > 28:
957 if int(vat[3:5]) == 2 and int(vat[1:3]) % 4 == 0:
958 if int(vat[5:7]) < 1 or int(vat[5:7]) > 29:
960 if int(vat[3:5]) in (4, 6, 9, 11):
961 if int(vat[5:7]) < 1 or int(vat[5:7]) > 30:
963 if int(vat[3:5]) in (1, 3, 5, 7, 8, 10, 12):
964 if int(vat[5:7]) < 1 or int(vat[5:7]) > 31:
967 sum = 2 * int(vat[0]) + 7 * int(vat[1]) + 9 * int(vat[2]) + \
968 1 * int(vat[3]) + 4 * int(vat[4]) + 6 * int(vat[5]) + \
969 3 * int(vat[6]) + 5 * int(vat[7]) + 8 * int(vat[8]) + \
970 2 * int(vat[9]) + 7 * int(vat[10]) + 9 * int(vat[11])
974 if check != int(vat[12]):
979 def check_vat_se(self, vat):
981 Check Sweden VAT number.
990 if int(vat[9:11]) < 0:
993 sum = mult_add(2, int(vat[0])) + int(vat[1]) + \
994 mult_add(2, int(vat[2])) + int(vat[3]) + \
995 mult_add(2, int(vat[4])) + int(vat[5]) + \
996 mult_add(2, int(vat[6])) + int(vat[7]) + \
997 mult_add(2, int(vat[8]))
998 check = 10 - (sum % 10)
1001 if check != int(vat[9]):
1005 def check_vat_si(self, vat):
1007 Check Slovenia VAT number.
1015 if int(vat[0:7]) <= 999999:
1018 sum = 8 * int(vat[0]) + 7 * int(vat[1]) + 6 * int(vat[2]) + \
1019 5 * int(vat[3]) + 4 * int(vat[4]) + 3 * int(vat[5]) + \
1021 check = 11 - (sum % 11)
1026 if check != int(vat[7]):
1030 def check_vat_sk(self, vat):
1032 Check Slovakia VAT number.
1038 if len(vat) not in(9, 10):
1041 if int(vat[0:2]) in (0, 10, 20) and len(vat) == 10:
1045 if int(vat[0:2]) < 54 or int(vat[0:2]) > 99:
1049 if int(vat[0:2]) > 53 :
1052 if int(vat[2:4]) < 1:
1054 if int(vat[2:4]) > 12 and int(vat[2:4]) < 51:
1056 if int(vat[2:4]) > 62:
1058 if int(vat[2:4]) in (2, 52) and int(vat[0:2]) % 4 > 0:
1059 if int(vat[4:6]) < 1 or int(vat[4:6]) > 28:
1061 if int(vat[2:4]) in (2, 52) and int(vat[0:2]) % 4 == 0:
1062 if int(vat[4:6]) < 1 or int(vat[4:6]) > 29:
1064 if int(vat[2:4]) in (4, 6, 9, 11, 54, 56, 59, 61):
1065 if int(vat[4:6]) < 1 or int(vat[4:6]) > 30:
1067 if int(vat[2:4]) in (1, 3, 5, 7, 8, 10, 12,
1068 51, 53, 55, 57, 58, 60, 62):
1069 if int(vat[4:6]) < 1 or int(vat[4:6]) > 31:
1073 def check_vat_mx(self, vat):
1075 Verificar RFC méxico
1077 if not 12 <= len(vat) <= 13:
1079 elif len(vat)==12 and not vat[:3].isalpha() | vat[3:9].isdigit() | vat[-3:].isalnum():
1081 elif len(vat)==13 and not vat[:4].isalpha() | vat[4:10].isdigit() | vat[-3:].isalnum():
1086 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: