Added support for Norwegian VAT no

bzr revid: rora@adego.no-20110419101734-c8q8sb2aku83y1sg
This commit is contained in:
Rolv Råen rora@adego.no 2011-04-19 12:17:34 +02:00
parent 2c3c064a22
commit 55fe4ab796
1 changed files with 28 additions and 1 deletions

View File

@ -39,7 +39,7 @@ _ref_vat = {
'pt': 'PT123456789', 'ro': 'RO1234567897',
'se': 'SE123456789701', 'si': 'SI12345679',
'sk': 'SK0012345675', 'el': 'EL12345670',
'mx': 'MXABC123456T1B'
'mx': 'MXABC123456T1B', 'no': 'NO123456785'
}
@ -1077,6 +1077,33 @@ class res_partner(osv.osv):
elif len(vat)==13 and not vat[:4].isalpha() | vat[4:10].isdigit() | vat[-3:].isalnum():
return False
return True
def check_vat_no(self, vat):
'''
Check Norway VAT number.
'''
if len(vat) != 9:
return False
try:
int(vat)
except:
return False
sum = (3 * int(vat[0])) + (2 * int(vat[1])) + \
(7 * int(vat[2])) + (6 * int(vat[3])) + \
(5 * int(vat[4])) + (4 * int(vat[5])) + \
(3 * int(vat[6])) + (2 * int(vat[7]))
check = 11 -(sum % 11)
if check == 11:
check = 0
if check == 10:
check -1
return False
if check != int(vat[8]):
return False
return True
res_partner()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: