https://ceed.rs.gov.br/matriz_common/versions/2.1.5/js/procergs/matriz.datatypes.ie.js?2.1.5.161.6+1
1matriz = matriz || {}; 2matriz.datatype = matriz.datatype || {} 3matriz.datatype.IE = function (ie) { 4 //Validação de Inscrição Estadual (Apenas RS) 5 validaSomenteNumeros(); 6 validaTamanho(); 7 validaDigitoVerificador(); 8 9 return { 10 asString: function() { 11 return ie; 12 } 13 }; 14 15 function validaSomenteNumeros() { 16 let regIE = /^[0-9]+$/g; 17 let match = ie.match(regIE); 18 19 if (!match) { 20 throw new Error('Inscrição Estadual deve ser composto por apenas números.'); 21 } 22 return ie; 23 } 24 25 function validaTamanho() { 26 if (ie.length != 10) { 27 throw new Error("Inscrição Estadual deve possuir 10 digitos."); 28 } 29 return ie; 30 } 31 32 function validaDigitoVerificador() { 33 var ieDigito = ie.substring(0, 10); 34 var digitoCalculado = calculaDigito(ieDigito); 35 36 if (digitoCalculado !== parseInt(ie[9])) { 37 throw new Error("Inscrição Estadual inválida, pois o digito verificador não está correto."); 38 } 39 } 40 41 function calculaDigito(cnpjDigito) { 42 var soma = somaDigito(cnpjDigito); 43 return mod11(soma); 44 } 45 46 function somaDigito(ieDigito) { 47 //var inicio = cnpjDigito.length - 1; 48 var fator = 2; 49 var soma = 0; 50 51 for (let i = 0; i <= 8; i++) { 52 soma = soma + (parseInt(ieDigito[i]) * fator); 53 fator--; 54 if(fator === 1){ 55 fator = 9; 56 } 57 58 } 59 return soma; 60 } 61 62 function mod11(soma) { 63 var mod11 = soma % 11; 64 let diff = 11 - mod11; 65 if (diff >= 10) { 66 return 0; 67 } else { 68 return diff; 69 } 70 } 71};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.