borni-dhifi / vatnumber

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

Italy Vat validation problem #14

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
>>> import vatnumber
>>> vatnumber.check_vat('IT00118439991')
False

This is a valid IT VAT number according to:
http://ec.europa.eu/taxation_customs/vies/viesquer.do

What is the expected output? What do you see instead?
* It should be TRUE

What version of the product are you using? On what operating system?
* 0.9

Please provide any additional information below.
def check_vat_it(vat):
    '''
    Check Italy VAT number.
    '''
    if len(vat) != 11:
        return False
    try:
        int(vat)
    except ValueError:
        return False
    if int(vat[0:7]) <= 0:
        return False
    if int(vat[7:10]) <= 0:
        return False
    if int(vat[7:10]) > 100 and int(vat[7:10]) < 120:
        return False

    check_sum = int(vat[0]) + mult_add(2, int(vat[1])) + int(vat[2]) + \
            mult_add(2, int(vat[3])) + int(vat[4]) + \
            mult_add(2, int(vat[5])) + int(vat[6]) + \
            mult_add(2, int(vat[7])) + int(vat[8]) + \
            mult_add(2, int(vat[9]))
    check = 10 - (check_sum % 10)
    if check == 10:
        check = 0
    if check != int(vat[10]):
        return False
    return True

This will fix the varification

Original issue reported on code.google.com by micku1...@gmail.com on 4 Jul 2011 at 7:18

GoogleCodeExporter commented 8 years ago
Is this a fiscal code for individuals?
Normally, the number vat[7:10] must be the province of residence so what does 
it mean here because it is equal to 999?

Original comment by cedric.krier@b2ck.com on 4 Jul 2011 at 8:02

GoogleCodeExporter commented 8 years ago
Hello,

I try to find out what 999 is here but unable to find exact information.
It should be province of residence.

Thanks,
Purnendu Singh(OpenERP)

Original comment by micku1...@gmail.com on 4 Jul 2011 at 1:28

GoogleCodeExporter commented 8 years ago
999 and 888 are valid province of residence according to 
http://books.google.com/books?id=3q_dWSNVYhYC&pg=PA595&lpg=PA595&dq=uffici+iva+c
odice+999&source=bl&ots=Glbb7C8RX-&sig=oXm6jrgpYFbWh5UHuTkxA5Tv2NY&hl=it&ei=8rix
TN37GM7GswaUudjLDQ&sa=X&oi=book_result&ct=result&resnum=6&ved=0CDUQ6AEwBQ#v=onep
age&q=uffici%20iva%20codice%20999&f=false

Original comment by cedric.krier@b2ck.com on 6 Jul 2011 at 8:55

GoogleCodeExporter commented 8 years ago
Fixed re7b5fc0ac899

Original comment by cedric.krier@b2ck.com on 6 Jul 2011 at 8:57

GoogleCodeExporter commented 8 years ago
Thanks for your support.

regards,
Purnendu Singh(OpenERP)

Original comment by micku1...@gmail.com on 6 Jul 2011 at 9:26