Posted By

eliluminado on 02/13/12


Tagged

cuit


Versions (?)

Validar CUIT


 / Published in: Python
 

URL: http://www.codigopython.com.ar/

Validar el numero de CUIT usando la forma '00-00000000-0'

Visto en: http://python.org.ar/pyar/Recetario/ValidarCuit

  1. def esCUITValida(cuit):
  2. # validaciones minimas
  3. if len(cuit) != 13 or cuit[2] != "-" or cuit[11] != "-":
  4. return False
  5.  
  6. base = [5, 4, 3, 2, 7, 6, 5, 4, 3, 2]
  7.  
  8. cuit = cuit.replace("-", "") # remuevo las barras
  9.  
  10. # calculo el digito verificador:
  11. aux = 0
  12. for i in xrange(10):
  13. aux += int(cuit[i]) * base[i]
  14.  
  15. aux = 11 - (aux - (int(aux / 11) * 11))
  16.  
  17. if aux == 11:
  18. aux = 0
  19. if aux == 10:
  20. aux = 9
  21.  
  22. return aux == int(cuit[10])

Report this snippet  

You need to login to post a comment.