Created
July 10, 2012 03:11
-
-
Save santagada/3080729 to your computer and use it in GitHub Desktop.
função de digito verificador
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from itertools import cycle | |
class A(object): | |
def nfe_digito_verificador(self, key): | |
numeros = reversed(map(int, key)) | |
soma = sum(n * m for n, m in zip(numeros, cycle(range(2,10)))) | |
resto = soma % 11 | |
if resto < 2: | |
return 0 | |
else: | |
return 11 - resto |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment