function validate_dfe_key(key){
var mult = [2,3,4,5,6,7,8,9];
var total = 0;
for(var i=43;i>0;i--){
total += key.substr(i-1,1) * mult[(43-i) % 8];
}
var result = total % 11;
if(result === 0 || result == 1){
result = 0;
}else{
result = 11 - result;
}
if(key.substr(43,1) != result){
return false;
}
return true;
}
Check the verifying digit of brazilian DF-e, like NF-e, NFC-e, CT-e, WTF-e and etc.
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.