[FIX] base_vat: support Irish Tax numbers introduced in 2013
This is a temporary fix until upstream is fixed. References: - http://en.wikipedia.org/wiki/Personal_Public_Service_Number - https://www.welfare.ie/en/Pages/Extension-of-the-Personal-Public-Service-Number-Range.aspx bzr revid: odo@openerp.com-20140213141246-t56sx1t8x4riey4w
This commit is contained in:
parent
234a27091e
commit
07c2c5ddd8
|
@ -54,7 +54,7 @@ _ref_vat = {
|
|||
'gr': 'GR12345670',
|
||||
'hu': 'HU12345676',
|
||||
'hr': 'HR01234567896', # Croatia, contributed by Milan Tribuson
|
||||
'ie': 'IE1234567T',
|
||||
'ie': 'IE1234567FA',
|
||||
'it': 'IT12345670017',
|
||||
'lt': 'LT123456715',
|
||||
'lu': 'LU12345613',
|
||||
|
@ -190,6 +190,34 @@ class res_partner(osv.osv):
|
|||
return check == int(num[8])
|
||||
return False
|
||||
|
||||
def _ie_check_char(self, vat):
|
||||
vat = vat.zfill(8)
|
||||
extra = 0
|
||||
if vat[7] not in ' W':
|
||||
if vat[7].isalpha():
|
||||
extra = 9 * (ord(vat[7]) - 64)
|
||||
else:
|
||||
# invalid
|
||||
return -1
|
||||
checksum = extra + sum((8-i) * int(x) for i, x in enumerate(vat[:7]))
|
||||
return 'WABCDEFGHIJKLMNOPQRSTUV'[checksum % 23]
|
||||
|
||||
def check_vat_ie(self, vat):
|
||||
""" Temporary Ireland VAT validation to support the new format
|
||||
introduced in January 2013 in Ireland, until upstream is fixed.
|
||||
TODO: remove when fixed upstream"""
|
||||
if len(vat) not in (8, 9) or not vat[2:7].isdigit():
|
||||
return False
|
||||
if len(vat) == 8:
|
||||
# Normalize pre-2013 numbers: final space or 'W' not significant
|
||||
vat += ' '
|
||||
if vat[:7].isdigit():
|
||||
return vat[7] == self._ie_check_char(vat[:7] + vat[8])
|
||||
elif vat[1] in (string.ascii_uppercase + '+*'):
|
||||
# Deprecated format
|
||||
# See http://www.revenue.ie/en/online/third-party-reporting/reporting-payment-details/faqs.html#section3
|
||||
return vat[7] == self._ie_check_char(vat[2:7] + vat[0] + vat[8])
|
||||
return False
|
||||
|
||||
# Mexican VAT verification, contributed by <moylop260@hotmail.com>
|
||||
# and Panos Christeas <p_christ@hol.gr>
|
||||
|
|
Loading…
Reference in New Issue