1 |
""" |
""" |
2 |
algoritmo de validacion del CUIL/CUIT |
algoritmo de validacion del CUIL/CUIT |
3 |
""" |
""" |
4 |
import re |
from re import sub |
5 |
|
|
6 |
|
def normalize (cuit): |
7 |
|
# this should be replaced w/ a input mask |
8 |
|
cuit= sub ('-', '', cuit) |
9 |
|
return (cuit) |
10 |
|
|
11 |
def validate (cuit): |
def validate (cuit): |
12 |
|
""" |
13 |
|
validates the cuit. the cuit should be normalized. |
14 |
|
""" |
15 |
# puede venir con o sin 'dashes' |
# puede venir con o sin 'dashes' |
16 |
if not cuit or cuit=='': |
if not cuit or cuit=='': |
17 |
return 1 |
return 1 |
|
matcher= re.compile ('(\d\d)\-(\d\d\d\d\d\d\d\d)\-(\d)') |
|
|
matches= matcher.match (cuit) |
|
|
if matches: |
|
|
cuit= "%s%s%s" % (matches.group (1), matches.group (2), matches.group (3)) |
|
18 |
|
|
|
# once unified, validate |
|
19 |
magic= '5432765432' |
magic= '5432765432' |
20 |
# first 10 digits |
# first 10 digits |
21 |
data= cuit[:10] |
data= cuit[:10] |