borni-dhifi / vatnumber

Automatically exported from code.google.com/p/vatnumber
GNU General Public License v3.0
0 stars 0 forks source link

VAT for Chile, South America #5

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
The VAT number verification for Chile "Called RUT", is:

def check_vat_cl(vat):
    '''
    Check Chile VAT number. Called RUT
    '''
    try:
        int(str(vat)[:len(str(vat))-1])
    except ValueError:
        return False
    sum = 0
    RUTLen = len(str(vat))
    for i in range (RUTLen - 2, -1, -1):
        sum += int(str(vat)[i]) * (((RUTLen - 2 - i) % 6) + 2)
    Resto = 11 - (sum % 11)
    if Resto == 11:
        return str(vat)[len(str(vat)) -1] == '0'
    elif Resto == 10:
        return str(vat)[len(str(vat)) -1] in ('K', 'k')
    else:
        return str(Resto) == str(vat)[len(str(vat)) -1]

Original issue reported on code.google.com by juanf.ja...@gtempaccount.com on 4 Sep 2009 at 8:15

GoogleCodeExporter commented 8 years ago
Fix with changeset 3dac77ae9daa

Original comment by cedric.krier@b2ck.com on 13 Nov 2009 at 5:50

GoogleCodeExporter commented 8 years ago

Original comment by cedric.krier@b2ck.com on 13 Nov 2009 at 5:51