[ADD] base_vat: add VAT validation for Peruvian localization.
This commit is contained in:
parent
a5531c1d29
commit
93127099c9
|
@ -63,6 +63,7 @@ _ref_vat = {
|
|||
'mx': 'MXABC123456T1B',
|
||||
'nl': 'NL123456782B90',
|
||||
'no': 'NO123456785',
|
||||
'pe': 'PER10254824220 or PED10254824220',
|
||||
'pl': 'PL1234567883',
|
||||
'pt': 'PT123456789',
|
||||
'ro': 'RO1234567897',
|
||||
|
@ -219,7 +220,7 @@ class res_partner(osv.osv):
|
|||
return vat[7] == self._ie_check_char(vat[2:7] + vat[0] + vat[8])
|
||||
return False
|
||||
|
||||
# Mexican VAT verification, contributed by <moylop260@hotmail.com>
|
||||
# Mexican VAT verification, contributed by Vauxoo
|
||||
# and Panos Christeas <p_christ@hol.gr>
|
||||
__check_vat_mx_re = re.compile(r"(?P<primeras>[A-Za-z\xd1\xf1&]{3,4})" \
|
||||
r"[ \-_]?" \
|
||||
|
@ -276,6 +277,41 @@ class res_partner(osv.osv):
|
|||
return False
|
||||
return check == int(vat[8])
|
||||
|
||||
# Peruvian VAT validation, contributed by Vauxoo
|
||||
def check_vat_pe(self, vat):
|
||||
|
||||
vat_type,vat = vat and len(vat)>=2 and (vat[0], vat[1:]) or (False, False)
|
||||
|
||||
if vat_type and vat_type.upper() == 'D':
|
||||
#DNI
|
||||
return True
|
||||
elif vat_type and vat_type.upper() == 'R':
|
||||
#verify RUC
|
||||
factor = '5432765432'
|
||||
sum = 0
|
||||
dig_check = False
|
||||
if len(vat) != 11:
|
||||
return False
|
||||
try:
|
||||
int(vat)
|
||||
except ValueError:
|
||||
return False
|
||||
|
||||
for f in range(0,10):
|
||||
sum += int(factor[f]) * int(vat[f])
|
||||
|
||||
subtraction = 11 - (sum % 11)
|
||||
if subtraction == 10:
|
||||
dig_check = 0
|
||||
elif subtraction == 11:
|
||||
dig_check = 1
|
||||
else:
|
||||
dig_check = subtraction
|
||||
|
||||
return int(vat[10]) == dig_check
|
||||
else:
|
||||
return False
|
||||
|
||||
res_partner()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
Loading…
Reference in New Issue