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', 'no': 'NO123456785'
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):
68 check = getattr(self, 'check_vat_' + vat_country)
69 if not check(vat_number):
73 def vat_change(self, cr, uid, ids, value, context=None):
74 return {'value': {'vat_subjected': bool(value)}}
77 '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.")
80 def _construct_constraint_msg(self, cr, uid, ids, context=None):
81 def default_vat_check(cn, vn):
82 # by default, a VAT number is valid if:
83 # it starts with 2 letters
84 # has more than 3 characters
85 return cn[0] in string.ascii_lowercase and cn[1] in string.ascii_lowercase
86 vat_country, vat_number = self._split_vat(self.browse(cr, uid, ids)[0].vat)
87 if default_vat_check(vat_country, vat_number):
88 vat_no = vat_country in _ref_vat and _ref_vat[vat_country] or 'Country Code + Vat Number'
89 return _('The Vat does not seems to be correct. You should have entered something like this %s'), (vat_no)
90 return _('The VAT is invalid, It should begin with the country code'), ()
92 _constraints = [(check_vat, _construct_constraint_msg, ["vat"])]
94 # code from the following methods come from Tryton (B2CK)
95 # http://www.tryton.org/hgwebdir.cgi/modules/relationship/file/544d1de586d9/party.py
96 def check_vat_at(self, vat):
98 Check Austria VAT number.
109 sum = int(num[0]) + mult_add(2, int(num[1])) + \
110 int(num[2]) + mult_add(2, int(num[3])) + \
111 int(num[4]) + mult_add(2, int(num[5])) + \
113 check = 10 - ((sum + 4) % 10)
116 if int(vat[-1:]) != check:
120 def check_vat_be(self, vat):
122 Check Belgium VAT number.
130 if int(vat[-2:]) != \
131 97 - (int(vat[:8]) % 97):
135 def check_vat_bg(self, vat):
137 Check Bulgaria VAT number.
139 if len(vat) not in [9,10]:
145 if int(vat[0]) in (2, 3) and \
148 sum = 4 * int(vat[0]) + 3 * int(vat[1]) + 2 * int(vat[2]) + \
149 7 * int(vat[3]) + 6 * int(vat[4]) + 5 * int(vat[5]) + \
150 4 * int(vat[6]) + 3 * int(vat[7]) + 2 * int(vat[8])
151 check = 11 - (sum % 11)
156 def check_vat_cy(self, vat):
158 Check Cyprus VAT number.
202 sum = n0 + n1 + n2 + n3 + n4 + n5 + n6 + n7
203 check = chr(sum % 26 + 65)
208 def check_vat_cz(self, vat):
210 Check Czech Republic VAT number.
212 if len(vat) not in (8, 9, 10):
220 if int(vat[0]) not in (0, 1, 2, 3, 4, 5, 6, 7, 8):
222 sum = 8 * int(vat[0]) + 7 * int(vat[1]) + 6 * int(vat[2]) + \
223 5 * int(vat[3]) + 4 * int(vat[4]) + 3 * int(vat[5]) + \
225 check = 11 - (sum % 11)
230 if check != int(vat[7]):
232 elif len(vat) == 9 and int(vat[0]) == 6:
233 sum = 8 * int(vat[1]) + 7 * int(vat[2]) + 6 * int(vat[3]) + \
234 5 * int(vat[4]) + 4 * int(vat[5]) + 3 * int(vat[6]) + \
236 check = 9 - ((11 - (sum % 11)) % 10)
237 if check != int(vat[8]):
240 if int(vat[0:2]) > 53 and int(vat[0:2]) < 80:
242 if int(vat[2:4]) < 1:
244 if int(vat[2:4]) > 12 and int(vat[2:4]) < 51:
246 if int(vat[2:4]) > 62:
248 if int(vat[2:4]) in (2, 52) and int(vat[0:2]) % 4 > 0:
249 if int(vat[4:6]) < 1:
251 if int(vat[4:6]) > 28:
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]) > 29:
258 if int(vat[2:4]) in (4, 6, 9, 11, 54, 56, 59, 61):
259 if int(vat[4:6]) < 1:
261 if int(vat[4:6]) > 30:
263 if int(vat[2:4]) in (1, 3, 5, 7, 8, 10, 12, 51,
264 53, 55, 57, 58, 60, 62):
265 if int(vat[4:6]) < 1:
267 if int(vat[4:6]) > 31:
270 if int(vat[0:2]) < 54:
272 if int(vat[2:4]) < 1:
274 if int(vat[2:4]) > 12 and int(vat[2:4]) < 51:
276 if int(vat[2:4]) > 62:
278 if int(vat[2:4]) in (2, 52) and int(vat[0:2]) % 4 > 0:
279 if int(vat[4:6]) < 1:
281 if int(vat[4:6]) > 28:
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]) > 29:
288 if int(vat[2:4]) in (4, 6, 9, 11, 54, 56, 59, 61):
289 if int(vat[4:6]) < 1:
291 if int(vat[4:6]) > 30:
293 if int(vat[2:4]) in (1, 3, 5, 7, 8, 10, 12, 51,
294 53, 55, 57, 58, 60, 62):
295 if int(vat[4:6]) < 1:
297 if int(vat[4:6]) > 31:
299 if (int(vat[0:2]) + int(vat[2:4]) + int(vat[4:6]) + int(vat[6:8]) +
300 int(vat[8:10])) % 11 != 0:
302 if int(vat[0:10]) % 11 != 0:
306 def check_vat_de(self, vat):
308 Check Germany VAT number.
316 if int(vat[0:7]) <= 0:
320 sum = (2 * ((int(vat[i]) + sum + 9) % 10 + 1)) % 11
324 if int(vat[8]) != check:
328 def check_vat_dk(self, vat):
330 Check Denmark VAT number.
340 sum = 2 * int(vat[0]) + 7 * int(vat[1]) + 6 * int(vat[2]) + \
341 5 * int(vat[3]) + 4 * int(vat[4]) + 3 * int(vat[5]) + \
342 2 * int(vat[6]) + int(vat[7])
347 def check_vat_ee(self, vat):
349 Check Estonia VAT number.
357 sum = 3 * int(vat[0]) + 7 * int(vat[1]) + 1 * int(vat[2]) + \
358 3 * int(vat[3]) + 7 * int(vat[4]) + 1 * int(vat[5]) + \
359 3 * int(vat[6]) + 7 * int(vat[7])
360 check = 10 - (sum % 10)
363 if check != int(vat[8]):
367 def check_vat_es(self, vat):
369 Check Spain VAT number.
399 #Legal persons with profit aim
400 if vat[0] in ('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'U', 'V'):
405 sum = mult_add(2, int(vat[1])) + int(vat[2]) + \
406 mult_add(2, int(vat[3])) + int(vat[4]) + \
407 mult_add(2, int(vat[5])) + int(vat[6]) + \
408 mult_add(2, int(vat[7]))
409 check = 10 - (sum % 10)
413 #Legal persons with non-profit aim
414 elif vat[0] in ('N', 'P', 'Q', 'R', 'S', 'W'):
419 sum = mult_add(2, int(vat[1])) + int(vat[2]) + \
420 mult_add(2, int(vat[3])) + int(vat[4]) + \
421 mult_add(2, int(vat[5])) + int(vat[6]) + \
422 mult_add(2, int(vat[7]))
423 check = 10 - (sum % 10)
424 check = chr(check + 64)
428 #Foreign natural persons, under age 14 or non-residents
429 elif vat[0] in ('K', 'L', 'M', 'X', 'Y', 'Z'):
431 check_value = '1' + vat[1:8]
433 check_value = '2' + vat[1:8]
435 check_value = vat[1:8]
441 check = 1 + (int(check_value) % 23)
447 #Spanish natural persons
453 check = 1 + (int(vat[:8]) % 23)
460 def check_vat_fi(self, vat):
462 Check Finland VAT number.
470 sum = 7 * int(vat[0]) + 9 * int(vat[1]) + 10 * int(vat[2]) + \
471 5 * int(vat[3]) + 8 * int(vat[4]) + 4 * int(vat[5]) + \
473 check = 11 - (sum % 11)
478 if check != int(vat[7]):
482 def check_vat_fr(self, vat):
484 Check France VAT number.
502 check = ((int(vat[2:11]) * 100) + 12) % 97
503 if check != int(vat[0:2]):
507 conv = ['0', '1', '2', '3', '4', '5', '6', '7',
508 '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
509 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T',
510 'U', 'V', 'W', 'X', 'Y', 'Z']
511 if vat[0] not in conv \
512 or vat[1] not in conv:
514 c1 = conv.index(vat[0])
515 c2 = conv.index(vat[1])
518 sum = c1 * 24 + c2 - 10
520 sum = c1 * 34 + c2 - 100
523 sum = (int(sum) / 11) + 1
524 y = (int(vat[2:11]) + sum) % 11
529 def check_vat_gb(self, vat):
531 Check United Kingdom VAT number.
541 if int(vat[2:5]) >= 500:
545 if int(vat[2:5]) < 500:
549 elif len(vat) in (9, 10):
555 if int(vat[0:7]) < 1:
557 if int(vat[0:7]) > 19999 and int(vat[0:7]) < 1000000:
559 if int(vat[7:9]) > 97:
561 if len(vat) == 10 and int(vat[9]) != 3:
564 sum = 8 * int(vat[0]) + 7 * int(vat[1]) + 6 * int(vat[2]) + \
565 5 * int(vat[3]) + 4 * int(vat[4]) + 3 * int(vat[5]) + \
566 2 * int(vat[6]) + 10 * int(vat[7]) + int(vat[8])
567 if int(vat[0:3]) > 100:
568 if sum % 97 not in (0, 55, 42):
574 elif len(vat) in (12, 13):
580 if int(vat[0:3]) not in (0, 1):
583 if int(vat[3:10]) < 1:
585 if int(vat[3:10]) > 19999 and int(vat[3:10]) < 1000000:
587 if int(vat[10:12]) > 97:
589 if len(vat) == 13 and int(vat[12]) != 3:
592 sum = 8 * int(vat[3]) + 7 * int(vat[4]) + 6 * int(vat[5]) + \
593 5 * int(vat[6]) + 4 * int(vat[7]) + 3 * int(vat[8]) + \
594 2 * int(vat[9]) + 10 * int(vat[10]) + int(vat[11])
600 def check_vat_gr(self, vat):
602 Check Greece VAT number.
609 sum = 128 * int(vat[0]) + 64 * int(vat[1]) + 32 * int(vat[2]) + \
610 16 * int(vat[3]) + 8 * int(vat[4]) + 4 * int(vat[5]) + \
615 if check != int(vat[7]):
619 sum = 256 * int(vat[0]) + 128 * int(vat[1]) + 64 * int(vat[2]) + \
620 32 * int(vat[3]) + 16 * int(vat[4]) + 8 * int(vat[5]) + \
621 4 * int(vat[6]) + 2 * int(vat[7])
625 if check != int(vat[8]):
630 def check_vat_el(self, vat):
631 return self.check_vat_gr(vat)
633 def check_vat_hu(self, vat):
635 Check Hungary VAT number.
645 sum = 9 * int(vat[0]) + 7 * int(vat[1]) + 3 * int(vat[2]) + \
646 1 * int(vat[3]) + 9 * int(vat[4]) + 7 * int(vat[5]) + \
648 check = 10 - (sum % 10)
651 if check != int(vat[7]):
655 def check_vat_ie(self, vat):
657 Check Ireland VAT number.
661 if (ord(vat[1]) >= 65 and ord(vat[1]) <= 90) \
662 or vat[1] in ('+', '*'):
672 sum = 7 * int(vat[2]) + 6 * int(vat[3]) + 5 * int(vat[4]) + \
673 4 * int(vat[5]) + 3 * int(vat[6]) + 2 * int(vat[0])
678 check = chr(check + 64)
688 sum = 8 * int(vat[0]) + 7 * int(vat[1]) + 6 * int(vat[2]) + \
689 5 * int(vat[3]) + 4 * int(vat[4]) + 3 * int(vat[5]) + \
695 check = chr(check + 64)
700 def check_vat_it(self, vat):
702 Check Italy VAT number.
710 if int(vat[0:7]) <= 0:
712 if int(vat[7:10]) <= 0:
714 if int(vat[7:10]) > 100 and int(vat[7:10]) < 120:
717 sum = int(vat[0]) + mult_add(2, int(vat[1])) + int(vat[2]) + \
718 mult_add(2, int(vat[3])) + int(vat[4]) + \
719 mult_add(2, int(vat[5])) + int(vat[6]) + \
720 mult_add(2, int(vat[7])) + int(vat[8]) + \
721 mult_add(2, int(vat[9]))
722 check = 10 - (sum % 10)
725 if check != int(vat[10]):
729 def check_vat_lt(self, vat):
731 Check Lithuania VAT number.
741 sum = 1 * int(vat[0]) + 2 * int(vat[1]) + 3 * int(vat[2]) + \
742 4 * int(vat[3]) + 5 * int(vat[4]) + 6 * int(vat[5]) + \
743 7 * int(vat[6]) + 8 * int(vat[7])
745 sum = 3 * int(vat[0]) + 4 * int(vat[1]) + 5 * int(vat[2]) + \
746 6 * int(vat[3]) + 7 * int(vat[4]) + 8 * int(vat[5]) + \
747 9 * int(vat[6]) + 1 * int(vat[7])
751 if check != int(vat[8]):
755 if int(vat[10]) != 1:
757 sum = 1 * int(vat[0]) + 2 * int(vat[1]) + 3 * int(vat[2]) + \
758 4 * int(vat[3]) + 5 * int(vat[4]) + 6 * int(vat[5]) + \
759 7 * int(vat[6]) + 8 * int(vat[7]) + 9 * int(vat[8]) + \
760 1 * int(vat[9]) + 2 * int(vat[10])
762 sum = 3 * int(vat[0]) + 4 * int(vat[1]) + 5 * int(vat[2]) + \
763 6 * int(vat[3]) + 7 * int(vat[4]) + 8 * int(vat[5]) + \
764 9 * int(vat[6]) + 1 * int(vat[7]) + 2 * int(vat[8]) + \
765 3 * int(vat[9]) + 4 * int(vat[10])
769 if check != int(vat[11]):
774 def check_vat_lu(self, vat):
776 Check Luxembourg VAT number.
784 if int(vat[0:6]) <= 0:
786 check = int(vat[0:6]) % 89
787 if check != int(vat[6:8]):
791 def check_vat_lv(self, vat):
793 Check Latvia VAT number.
802 sum = 9 * int(vat[0]) + 1 * int(vat[1]) + 4 * int(vat[2]) + \
803 8 * int(vat[3]) + 3 * int(vat[4]) + 10 * int(vat[5]) + \
804 2 * int(vat[6]) + 5 * int(vat[7]) + 7 * int(vat[8]) + \
806 if sum % 11 == 4 and int(vat[0]) == 9:
809 check = 4 - (sum % 11)
811 check = 14 - (sum % 11)
813 check = 3 - (sum % 11)
814 if check != int(vat[10]):
818 if int(vat[2:4]) == 2 and int(vat[4:6]) % 4 > 0:
819 if int(vat[0:2]) < 1 or int(vat[0:2]) > 28:
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]) > 29:
824 if int(vat[2:4]) in (4, 6, 9, 11):
825 if int(vat[0:2]) < 1 or int(vat[0:2]) > 30:
827 if int(vat[2:4]) in (1, 3, 5, 7, 8, 10, 12):
828 if int(vat[0:2]) < 1 or int(vat[0:2]) > 31:
830 if int(vat[2:4]) < 1 or int(vat[2:4]) > 12:
834 def check_vat_mt(self, vat):
836 Check Malta VAT number.
845 if int(vat[0:6]) < 100000:
848 sum = 3 * int(vat[0]) + 4 * int(vat[1]) + 6 * int(vat[2]) + \
849 7 * int(vat[3]) + 8 * int(vat[4]) + 9 * int(vat[5])
850 check = 37 - (sum % 37)
851 if check != int(vat[6:8]):
855 def check_vat_nl(self, vat):
857 Check Netherlands VAT number.
866 if int(vat[0:8]) <= 0:
871 sum = 9 * int(vat[0]) + 8 * int(vat[1]) + 7 * int(vat[2]) + \
872 6 * int(vat[3]) + 5 * int(vat[4]) + 4 * int(vat[5]) + \
873 3 * int(vat[6]) + 2 * int(vat[7])
878 if check != int(vat[8]):
882 def check_vat_pl(self, vat):
884 Check Poland VAT number.
893 sum = 6 * int(vat[0]) + 5 * int(vat[1]) + 7 * int(vat[2]) + \
894 2 * int(vat[3]) + 3 * int(vat[4]) + 4 * int(vat[5]) + \
895 5 * int(vat[6]) + 6 * int(vat[7]) + 7 * int(vat[8])
899 if check != int(vat[9]):
903 def check_vat_pt(self, vat):
905 Check Portugal VAT number.
917 sum = 9 * int(vat[0]) + 8 * int(vat[1]) + 7 * int(vat[2]) + \
918 6 * int(vat[3]) + 5 * int(vat[4]) + 4 * int(vat[5]) + \
919 3 * int(vat[6]) + 2 * int(vat[7])
920 check = 11 - (sum % 11)
921 if check == 10 or check == 11:
925 def check_vat_ro(self, vat):
927 Check Romania VAT number.
934 if len(vat) >= 2 and len(vat) <= 10:
935 vat = (10 - len(vat)) * '0' + vat
936 sum = 7 * int(vat[0]) + 5 * int(vat[1]) + 3 * int(vat[2]) + \
937 2 * int(vat[3]) + 1 * int(vat[4]) + 7 * int(vat[5]) + \
938 5 * int(vat[6]) + 3 * int(vat[7]) + 2 * int(vat[8])
939 check = (sum * 10) % 11
942 if check != int(vat[9]):
946 if int(vat[0]) not in (1, 2, 3, 4, 6):
948 if int(vat[3:5]) < 1 or int(vat[3:5]) > 12:
950 if int(vat[3:5]) == 2 and int(vat[1:3]) % 4 > 0:
951 if int(vat[5:7]) < 1 or int(vat[5:7]) > 28:
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]) > 29:
956 if int(vat[3:5]) in (4, 6, 9, 11):
957 if int(vat[5:7]) < 1 or int(vat[5:7]) > 30:
959 if int(vat[3:5]) in (1, 3, 5, 7, 8, 10, 12):
960 if int(vat[5:7]) < 1 or int(vat[5:7]) > 31:
963 sum = 2 * int(vat[0]) + 7 * int(vat[1]) + 9 * int(vat[2]) + \
964 1 * int(vat[3]) + 4 * int(vat[4]) + 6 * int(vat[5]) + \
965 3 * int(vat[6]) + 5 * int(vat[7]) + 8 * int(vat[8]) + \
966 2 * int(vat[9]) + 7 * int(vat[10]) + 9 * int(vat[11])
970 if check != int(vat[12]):
975 def check_vat_se(self, vat):
977 Check Sweden VAT number.
986 if int(vat[9:11]) < 0:
989 sum = mult_add(2, int(vat[0])) + int(vat[1]) + \
990 mult_add(2, int(vat[2])) + int(vat[3]) + \
991 mult_add(2, int(vat[4])) + int(vat[5]) + \
992 mult_add(2, int(vat[6])) + int(vat[7]) + \
993 mult_add(2, int(vat[8]))
994 check = 10 - (sum % 10)
997 if check != int(vat[9]):
1001 def check_vat_si(self, vat):
1003 Check Slovenia VAT number.
1011 if int(vat[0:7]) <= 999999:
1014 sum = 8 * int(vat[0]) + 7 * int(vat[1]) + 6 * int(vat[2]) + \
1015 5 * int(vat[3]) + 4 * int(vat[4]) + 3 * int(vat[5]) + \
1017 check = 11 - (sum % 11)
1022 if check != int(vat[7]):
1026 def check_vat_sk(self, vat):
1028 Check Slovakia VAT number.
1034 if len(vat) not in(9, 10):
1037 if int(vat[0:2]) in (0, 10, 20) and len(vat) == 10:
1041 if int(vat[0:2]) < 54 or int(vat[0:2]) > 99:
1045 if int(vat[0:2]) > 53 :
1048 if int(vat[2:4]) < 1:
1050 if int(vat[2:4]) > 12 and int(vat[2:4]) < 51:
1052 if int(vat[2:4]) > 62:
1054 if int(vat[2:4]) in (2, 52) and int(vat[0:2]) % 4 > 0:
1055 if int(vat[4:6]) < 1 or int(vat[4:6]) > 28:
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]) > 29:
1060 if int(vat[2:4]) in (4, 6, 9, 11, 54, 56, 59, 61):
1061 if int(vat[4:6]) < 1 or int(vat[4:6]) > 30:
1063 if int(vat[2:4]) in (1, 3, 5, 7, 8, 10, 12,
1064 51, 53, 55, 57, 58, 60, 62):
1065 if int(vat[4:6]) < 1 or int(vat[4:6]) > 31:
1069 def check_vat_mx(self, vat):
1071 Verificar RFC méxico
1073 if not 12 <= len(vat) <= 13:
1075 elif len(vat)==12 and not vat[:3].isalpha() | vat[3:9].isdigit() | vat[-3:].isalnum():
1077 elif len(vat)==13 and not vat[:4].isalpha() | vat[4:10].isdigit() | vat[-3:].isalnum():
1081 def check_vat_no(self, vat):
1083 Check Norway VAT number.See http://www.brreg.no/english/coordination/number.html
1092 sum = (3 * int(vat[0])) + (2 * int(vat[1])) + \
1093 (7 * int(vat[2])) + (6 * int(vat[3])) + \
1094 (5 * int(vat[4])) + (4 * int(vat[5])) + \
1095 (3 * int(vat[6])) + (2 * int(vat[7]))
1097 check = 11 -(sum % 11)
1102 return check == int(vat[8])
1107 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: