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 _ref_vat.has_key(vat_country):
67 country_code = vat_country.upper()
68 code = self.pool.get('res.country').search(cr, uid, [('code', '=', country_code)])
71 if not hasattr(self, 'check_vat_' + vat_country):
73 check = getattr(self, 'check_vat_' + vat_country)
74 if not check(vat_number):
78 def vat_change(self, cr, uid, ids, value, context=None):
79 return {'value': {'vat_subjected': bool(value)}}
82 '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.")
85 def _construct_constraint_msg(self, cr, uid, ids, context=None):
86 def default_vat_check(cn, vn):
87 # by default, a VAT number is valid if:
88 # it starts with 2 letters
89 # has more than 3 characters
90 return cn[0] in string.ascii_lowercase and cn[1] in string.ascii_lowercase
91 vat_country, vat_number = self._split_vat(self.browse(cr, uid, ids)[0].vat)
92 if default_vat_check(vat_country, vat_number):
93 vat_no = vat_country in _ref_vat and _ref_vat[vat_country] or 'Country Code + Vat Number'
94 return _('The Vat does not seems to be correct. You should have entered something like this %s'), (vat_no)
95 return _('The VAT is invalid, It should begin with the country code'), ()
97 _constraints = [(check_vat, _construct_constraint_msg, ["vat"])]
99 # code from the following methods come from Tryton (B2CK)
100 # http://www.tryton.org/hgwebdir.cgi/modules/relationship/file/544d1de586d9/party.py
101 def check_vat_at(self, vat):
103 Check Austria VAT number.
114 sum = int(num[0]) + mult_add(2, int(num[1])) + \
115 int(num[2]) + mult_add(2, int(num[3])) + \
116 int(num[4]) + mult_add(2, int(num[5])) + \
118 check = 10 - ((sum + 4) % 10)
121 if int(vat[-1:]) != check:
125 def check_vat_be(self, vat):
127 Check Belgium VAT number.
135 if int(vat[-2:]) != \
136 97 - (int(vat[:8]) % 97):
140 def check_vat_bg(self, vat):
142 Check Bulgaria VAT number.
144 if len(vat) not in [9,10]:
150 if int(vat[0]) in (2, 3) and \
153 sum = 4 * int(vat[0]) + 3 * int(vat[1]) + 2 * int(vat[2]) + \
154 7 * int(vat[3]) + 6 * int(vat[4]) + 5 * int(vat[5]) + \
155 4 * int(vat[6]) + 3 * int(vat[7]) + 2 * int(vat[8])
156 check = 11 - (sum % 11)
161 def check_vat_cy(self, vat):
163 Check Cyprus VAT number.
207 sum = n0 + n1 + n2 + n3 + n4 + n5 + n6 + n7
208 check = chr(sum % 26 + 65)
213 def check_vat_cz(self, vat):
215 Check Czech Republic VAT number.
217 if len(vat) not in (8, 9, 10):
225 if int(vat[0]) not in (0, 1, 2, 3, 4, 5, 6, 7, 8):
227 sum = 8 * int(vat[0]) + 7 * int(vat[1]) + 6 * int(vat[2]) + \
228 5 * int(vat[3]) + 4 * int(vat[4]) + 3 * int(vat[5]) + \
230 check = 11 - (sum % 11)
235 if check != int(vat[7]):
237 elif len(vat) == 9 and int(vat[0]) == 6:
238 sum = 8 * int(vat[1]) + 7 * int(vat[2]) + 6 * int(vat[3]) + \
239 5 * int(vat[4]) + 4 * int(vat[5]) + 3 * int(vat[6]) + \
241 check = 9 - ((11 - (sum % 11)) % 10)
242 if check != int(vat[8]):
245 if int(vat[0:2]) > 53 and int(vat[0:2]) < 80:
247 if int(vat[2:4]) < 1:
249 if int(vat[2:4]) > 12 and int(vat[2:4]) < 51:
251 if int(vat[2:4]) > 62:
253 if int(vat[2:4]) in (2, 52) and int(vat[0:2]) % 4 > 0:
254 if int(vat[4:6]) < 1:
256 if int(vat[4:6]) > 28:
258 if int(vat[2:4]) in (2, 52) and int(vat[0:2]) % 4 == 0:
259 if int(vat[4:6]) < 1:
261 if int(vat[4:6]) > 29:
263 if int(vat[2:4]) in (4, 6, 9, 11, 54, 56, 59, 61):
264 if int(vat[4:6]) < 1:
266 if int(vat[4:6]) > 30:
268 if int(vat[2:4]) in (1, 3, 5, 7, 8, 10, 12, 51,
269 53, 55, 57, 58, 60, 62):
270 if int(vat[4:6]) < 1:
272 if int(vat[4:6]) > 31:
275 if int(vat[0:2]) < 54:
277 if int(vat[2:4]) < 1:
279 if int(vat[2:4]) > 12 and int(vat[2:4]) < 51:
281 if int(vat[2:4]) > 62:
283 if int(vat[2:4]) in (2, 52) and int(vat[0:2]) % 4 > 0:
284 if int(vat[4:6]) < 1:
286 if int(vat[4:6]) > 28:
288 if int(vat[2:4]) in (2, 52) and int(vat[0:2]) % 4 == 0:
289 if int(vat[4:6]) < 1:
291 if int(vat[4:6]) > 29:
293 if int(vat[2:4]) in (4, 6, 9, 11, 54, 56, 59, 61):
294 if int(vat[4:6]) < 1:
296 if int(vat[4:6]) > 30:
298 if int(vat[2:4]) in (1, 3, 5, 7, 8, 10, 12, 51,
299 53, 55, 57, 58, 60, 62):
300 if int(vat[4:6]) < 1:
302 if int(vat[4:6]) > 31:
304 if (int(vat[0:2]) + int(vat[2:4]) + int(vat[4:6]) + int(vat[6:8]) +
305 int(vat[8:10])) % 11 != 0:
307 if int(vat[0:10]) % 11 != 0:
311 def check_vat_de(self, vat):
313 Check Germany VAT number.
321 if int(vat[0:7]) <= 0:
325 sum = (2 * ((int(vat[i]) + sum + 9) % 10 + 1)) % 11
329 if int(vat[8]) != check:
333 def check_vat_dk(self, vat):
335 Check Denmark VAT number.
345 sum = 2 * int(vat[0]) + 7 * int(vat[1]) + 6 * int(vat[2]) + \
346 5 * int(vat[3]) + 4 * int(vat[4]) + 3 * int(vat[5]) + \
347 2 * int(vat[6]) + int(vat[7])
352 def check_vat_ee(self, vat):
354 Check Estonia VAT number.
362 sum = 3 * int(vat[0]) + 7 * int(vat[1]) + 1 * int(vat[2]) + \
363 3 * int(vat[3]) + 7 * int(vat[4]) + 1 * int(vat[5]) + \
364 3 * int(vat[6]) + 7 * int(vat[7])
365 check = 10 - (sum % 10)
368 if check != int(vat[8]):
372 def check_vat_es(self, vat):
374 Check Spain VAT number.
404 #Legal persons with profit aim
405 if vat[0] in ('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'U', 'V'):
410 sum = mult_add(2, int(vat[1])) + int(vat[2]) + \
411 mult_add(2, int(vat[3])) + int(vat[4]) + \
412 mult_add(2, int(vat[5])) + int(vat[6]) + \
413 mult_add(2, int(vat[7]))
414 check = 10 - (sum % 10)
418 #Legal persons with non-profit aim
419 elif vat[0] in ('N', 'P', 'Q', 'R', 'S', 'W'):
424 sum = mult_add(2, int(vat[1])) + int(vat[2]) + \
425 mult_add(2, int(vat[3])) + int(vat[4]) + \
426 mult_add(2, int(vat[5])) + int(vat[6]) + \
427 mult_add(2, int(vat[7]))
428 check = 10 - (sum % 10)
429 check = chr(check + 64)
433 #Foreign natural persons, under age 14 or non-residents
434 elif vat[0] in ('K', 'L', 'M', 'X', 'Y', 'Z'):
436 check_value = '1' + vat[1:8]
438 check_value = '2' + vat[1:8]
440 check_value = vat[1:8]
446 check = 1 + (int(check_value) % 23)
452 #Spanish natural persons
458 check = 1 + (int(vat[:8]) % 23)
465 def check_vat_fi(self, vat):
467 Check Finland VAT number.
475 sum = 7 * int(vat[0]) + 9 * int(vat[1]) + 10 * int(vat[2]) + \
476 5 * int(vat[3]) + 8 * int(vat[4]) + 4 * int(vat[5]) + \
478 check = 11 - (sum % 11)
483 if check != int(vat[7]):
487 def check_vat_fr(self, vat):
489 Check France VAT number.
507 check = ((int(vat[2:11]) * 100) + 12) % 97
508 if check != int(vat[0:2]):
512 conv = ['0', '1', '2', '3', '4', '5', '6', '7',
513 '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
514 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T',
515 'U', 'V', 'W', 'X', 'Y', 'Z']
516 if vat[0] not in conv \
517 or vat[1] not in conv:
519 c1 = conv.index(vat[0])
520 c2 = conv.index(vat[1])
523 sum = c1 * 24 + c2 - 10
525 sum = c1 * 34 + c2 - 100
528 sum = (int(sum) / 11) + 1
529 y = (int(vat[2:11]) + sum) % 11
534 def check_vat_gb(self, vat):
536 Check United Kingdom VAT number.
546 if int(vat[2:5]) >= 500:
550 if int(vat[2:5]) < 500:
554 elif len(vat) in (9, 10):
560 if int(vat[0:7]) < 1:
562 if int(vat[0:7]) > 19999 and int(vat[0:7]) < 1000000:
564 if int(vat[7:9]) > 97:
566 if len(vat) == 10 and int(vat[9]) != 3:
569 sum = 8 * int(vat[0]) + 7 * int(vat[1]) + 6 * int(vat[2]) + \
570 5 * int(vat[3]) + 4 * int(vat[4]) + 3 * int(vat[5]) + \
571 2 * int(vat[6]) + 10 * int(vat[7]) + int(vat[8])
572 if int(vat[0:3]) > 100:
573 if sum % 97 not in (0, 55, 42):
579 elif len(vat) in (12, 13):
585 if int(vat[0:3]) not in (0, 1):
588 if int(vat[3:10]) < 1:
590 if int(vat[3:10]) > 19999 and int(vat[3:10]) < 1000000:
592 if int(vat[10:12]) > 97:
594 if len(vat) == 13 and int(vat[12]) != 3:
597 sum = 8 * int(vat[3]) + 7 * int(vat[4]) + 6 * int(vat[5]) + \
598 5 * int(vat[6]) + 4 * int(vat[7]) + 3 * int(vat[8]) + \
599 2 * int(vat[9]) + 10 * int(vat[10]) + int(vat[11])
605 def check_vat_gr(self, vat):
607 Check Greece VAT number.
614 sum = 128 * int(vat[0]) + 64 * int(vat[1]) + 32 * int(vat[2]) + \
615 16 * int(vat[3]) + 8 * int(vat[4]) + 4 * int(vat[5]) + \
620 if check != int(vat[7]):
624 sum = 256 * int(vat[0]) + 128 * int(vat[1]) + 64 * int(vat[2]) + \
625 32 * int(vat[3]) + 16 * int(vat[4]) + 8 * int(vat[5]) + \
626 4 * int(vat[6]) + 2 * int(vat[7])
630 if check != int(vat[8]):
635 def check_vat_el(self, vat):
636 return self.check_vat_gr(vat)
638 def check_vat_hu(self, vat):
640 Check Hungary VAT number.
650 sum = 9 * int(vat[0]) + 7 * int(vat[1]) + 3 * int(vat[2]) + \
651 1 * int(vat[3]) + 9 * int(vat[4]) + 7 * int(vat[5]) + \
653 check = 10 - (sum % 10)
656 if check != int(vat[7]):
660 def check_vat_ie(self, vat):
662 Check Ireland VAT number.
666 if (ord(vat[1]) >= 65 and ord(vat[1]) <= 90) \
667 or vat[1] in ('+', '*'):
677 sum = 7 * int(vat[2]) + 6 * int(vat[3]) + 5 * int(vat[4]) + \
678 4 * int(vat[5]) + 3 * int(vat[6]) + 2 * int(vat[0])
683 check = chr(check + 64)
693 sum = 8 * int(vat[0]) + 7 * int(vat[1]) + 6 * int(vat[2]) + \
694 5 * int(vat[3]) + 4 * int(vat[4]) + 3 * int(vat[5]) + \
700 check = chr(check + 64)
705 def check_vat_it(self, vat):
707 Check Italy VAT number.
715 if int(vat[0:7]) <= 0:
717 if int(vat[7:10]) <= 0:
719 if int(vat[7:10]) > 100 and int(vat[7:10]) < 120:
722 sum = int(vat[0]) + mult_add(2, int(vat[1])) + int(vat[2]) + \
723 mult_add(2, int(vat[3])) + int(vat[4]) + \
724 mult_add(2, int(vat[5])) + int(vat[6]) + \
725 mult_add(2, int(vat[7])) + int(vat[8]) + \
726 mult_add(2, int(vat[9]))
727 check = 10 - (sum % 10)
730 if check != int(vat[10]):
734 def check_vat_lt(self, vat):
736 Check Lithuania VAT number.
746 sum = 1 * int(vat[0]) + 2 * int(vat[1]) + 3 * int(vat[2]) + \
747 4 * int(vat[3]) + 5 * int(vat[4]) + 6 * int(vat[5]) + \
748 7 * int(vat[6]) + 8 * int(vat[7])
750 sum = 3 * int(vat[0]) + 4 * int(vat[1]) + 5 * int(vat[2]) + \
751 6 * int(vat[3]) + 7 * int(vat[4]) + 8 * int(vat[5]) + \
752 9 * int(vat[6]) + 1 * int(vat[7])
756 if check != int(vat[8]):
760 if int(vat[10]) != 1:
762 sum = 1 * int(vat[0]) + 2 * int(vat[1]) + 3 * int(vat[2]) + \
763 4 * int(vat[3]) + 5 * int(vat[4]) + 6 * int(vat[5]) + \
764 7 * int(vat[6]) + 8 * int(vat[7]) + 9 * int(vat[8]) + \
765 1 * int(vat[9]) + 2 * int(vat[10])
767 sum = 3 * int(vat[0]) + 4 * int(vat[1]) + 5 * int(vat[2]) + \
768 6 * int(vat[3]) + 7 * int(vat[4]) + 8 * int(vat[5]) + \
769 9 * int(vat[6]) + 1 * int(vat[7]) + 2 * int(vat[8]) + \
770 3 * int(vat[9]) + 4 * int(vat[10])
774 if check != int(vat[11]):
779 def check_vat_lu(self, vat):
781 Check Luxembourg VAT number.
789 if int(vat[0:6]) <= 0:
791 check = int(vat[0:6]) % 89
792 if check != int(vat[6:8]):
796 def check_vat_lv(self, vat):
798 Check Latvia VAT number.
807 sum = 9 * int(vat[0]) + 1 * int(vat[1]) + 4 * int(vat[2]) + \
808 8 * int(vat[3]) + 3 * int(vat[4]) + 10 * int(vat[5]) + \
809 2 * int(vat[6]) + 5 * int(vat[7]) + 7 * int(vat[8]) + \
811 if sum % 11 == 4 and int(vat[0]) == 9:
814 check = 4 - (sum % 11)
816 check = 14 - (sum % 11)
818 check = 3 - (sum % 11)
819 if check != int(vat[10]):
823 if int(vat[2:4]) == 2 and int(vat[4:6]) % 4 > 0:
824 if int(vat[0:2]) < 1 or int(vat[0:2]) > 28:
826 if int(vat[2:4]) == 2 and int(vat[4:6]) % 4 == 0:
827 if int(vat[0:2]) < 1 or int(vat[0:2]) > 29:
829 if int(vat[2:4]) in (4, 6, 9, 11):
830 if int(vat[0:2]) < 1 or int(vat[0:2]) > 30:
832 if int(vat[2:4]) in (1, 3, 5, 7, 8, 10, 12):
833 if int(vat[0:2]) < 1 or int(vat[0:2]) > 31:
835 if int(vat[2:4]) < 1 or int(vat[2:4]) > 12:
839 def check_vat_mt(self, vat):
841 Check Malta VAT number.
850 if int(vat[0:6]) < 100000:
853 sum = 3 * int(vat[0]) + 4 * int(vat[1]) + 6 * int(vat[2]) + \
854 7 * int(vat[3]) + 8 * int(vat[4]) + 9 * int(vat[5])
855 check = 37 - (sum % 37)
856 if check != int(vat[6:8]):
860 def check_vat_nl(self, vat):
862 Check Netherlands VAT number.
871 if int(vat[0:8]) <= 0:
876 sum = 9 * int(vat[0]) + 8 * int(vat[1]) + 7 * int(vat[2]) + \
877 6 * int(vat[3]) + 5 * int(vat[4]) + 4 * int(vat[5]) + \
878 3 * int(vat[6]) + 2 * int(vat[7])
883 if check != int(vat[8]):
887 def check_vat_pl(self, vat):
889 Check Poland VAT number.
898 sum = 6 * int(vat[0]) + 5 * int(vat[1]) + 7 * int(vat[2]) + \
899 2 * int(vat[3]) + 3 * int(vat[4]) + 4 * int(vat[5]) + \
900 5 * int(vat[6]) + 6 * int(vat[7]) + 7 * int(vat[8])
904 if check != int(vat[9]):
908 def check_vat_pt(self, vat):
910 Check Portugal VAT number.
922 sum = 9 * int(vat[0]) + 8 * int(vat[1]) + 7 * int(vat[2]) + \
923 6 * int(vat[3]) + 5 * int(vat[4]) + 4 * int(vat[5]) + \
924 3 * int(vat[6]) + 2 * int(vat[7])
925 check = 11 - (sum % 11)
926 if check == 10 or check == 11:
930 def check_vat_ro(self, vat):
932 Check Romania VAT number.
939 if len(vat) >= 2 and len(vat) <= 10:
940 vat = (10 - len(vat)) * '0' + vat
941 sum = 7 * int(vat[0]) + 5 * int(vat[1]) + 3 * int(vat[2]) + \
942 2 * int(vat[3]) + 1 * int(vat[4]) + 7 * int(vat[5]) + \
943 5 * int(vat[6]) + 3 * int(vat[7]) + 2 * int(vat[8])
944 check = (sum * 10) % 11
947 if check != int(vat[9]):
951 if int(vat[0]) not in (1, 2, 3, 4, 6):
953 if int(vat[3:5]) < 1 or int(vat[3:5]) > 12:
955 if int(vat[3:5]) == 2 and int(vat[1:3]) % 4 > 0:
956 if int(vat[5:7]) < 1 or int(vat[5:7]) > 28:
958 if int(vat[3:5]) == 2 and int(vat[1:3]) % 4 == 0:
959 if int(vat[5:7]) < 1 or int(vat[5:7]) > 29:
961 if int(vat[3:5]) in (4, 6, 9, 11):
962 if int(vat[5:7]) < 1 or int(vat[5:7]) > 30:
964 if int(vat[3:5]) in (1, 3, 5, 7, 8, 10, 12):
965 if int(vat[5:7]) < 1 or int(vat[5:7]) > 31:
968 sum = 2 * int(vat[0]) + 7 * int(vat[1]) + 9 * int(vat[2]) + \
969 1 * int(vat[3]) + 4 * int(vat[4]) + 6 * int(vat[5]) + \
970 3 * int(vat[6]) + 5 * int(vat[7]) + 8 * int(vat[8]) + \
971 2 * int(vat[9]) + 7 * int(vat[10]) + 9 * int(vat[11])
975 if check != int(vat[12]):
980 def check_vat_se(self, vat):
982 Check Sweden VAT number.
991 if int(vat[9:11]) < 0:
994 sum = mult_add(2, int(vat[0])) + int(vat[1]) + \
995 mult_add(2, int(vat[2])) + int(vat[3]) + \
996 mult_add(2, int(vat[4])) + int(vat[5]) + \
997 mult_add(2, int(vat[6])) + int(vat[7]) + \
998 mult_add(2, int(vat[8]))
999 check = 10 - (sum % 10)
1002 if check != int(vat[9]):
1006 def check_vat_si(self, vat):
1008 Check Slovenia VAT number.
1016 if int(vat[0:7]) <= 999999:
1019 sum = 8 * int(vat[0]) + 7 * int(vat[1]) + 6 * int(vat[2]) + \
1020 5 * int(vat[3]) + 4 * int(vat[4]) + 3 * int(vat[5]) + \
1022 check = 11 - (sum % 11)
1027 if check != int(vat[7]):
1031 def check_vat_sk(self, vat):
1033 Check Slovakia VAT number.
1039 if len(vat) not in(9, 10):
1042 if int(vat[0:2]) in (0, 10, 20) and len(vat) == 10:
1046 if int(vat[0:2]) < 54 or int(vat[0:2]) > 99:
1050 if int(vat[0:2]) > 53 :
1053 if int(vat[2:4]) < 1:
1055 if int(vat[2:4]) > 12 and int(vat[2:4]) < 51:
1057 if int(vat[2:4]) > 62:
1059 if int(vat[2:4]) in (2, 52) and int(vat[0:2]) % 4 > 0:
1060 if int(vat[4:6]) < 1 or int(vat[4:6]) > 28:
1062 if int(vat[2:4]) in (2, 52) and int(vat[0:2]) % 4 == 0:
1063 if int(vat[4:6]) < 1 or int(vat[4:6]) > 29:
1065 if int(vat[2:4]) in (4, 6, 9, 11, 54, 56, 59, 61):
1066 if int(vat[4:6]) < 1 or int(vat[4:6]) > 30:
1068 if int(vat[2:4]) in (1, 3, 5, 7, 8, 10, 12,
1069 51, 53, 55, 57, 58, 60, 62):
1070 if int(vat[4:6]) < 1 or int(vat[4:6]) > 31:
1074 def check_vat_mx(self, vat):
1076 Verificar RFC méxico
1078 if not 12 <= len(vat) <= 13:
1080 elif len(vat)==12 and not vat[:3].isalpha() | vat[3:9].isdigit() | vat[-3:].isalnum():
1082 elif len(vat)==13 and not vat[:4].isalpha() | vat[4:10].isdigit() | vat[-3:].isalnum():
1087 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: