Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IE Goiás dando erro #286

Open
edilmar opened this issue Mar 6, 2023 · 1 comment
Open

IE Goiás dando erro #286

edilmar opened this issue Mar 6, 2023 · 1 comment

Comments

@edilmar
Copy link

edilmar commented Mar 6, 2023

Ao tentar validar a IE 200024825 em GO, usando IEGoiasValidator, da erro:

br.com.caelum.stella.validation.InvalidStateException: Validation errors: [IEError : INVALID DIGITS] at br.com.caelum.stella.validation.BaseValidator.assertValid(BaseValidator.java:64) at br.com.caelum.stella.validation.ie.AbstractIEValidator.assertValid(AbstractIEValidator.java:80) at br.com.caelum.stella.validation.ie.AbstractIEValidator.assertValid(AbstractIEValidator.java:17) at control.testes.Teste.main(Teste.java:92)

Sera que criaram nova regra de calculo?

Ao testar diversas outras IEs, funciona 100%.

@edilmar
Copy link
Author

edilmar commented Mar 7, 2023

Eu fiz o codigo abaixo e deu certo com a IE acima:

  long valorAux = Long.parseLong(valor.substring(0,TAMIEGO-1));
  if (valorAux >= 10103105 && valorAux <= 10119997)
    result = "1"; // fixo isso
  else {
    soma = 0;
    mult = 2;
    for (i = TAMIEGO-2; i >= 0; i--) {
      soma += Integer.parseInt(valor.substring(i,i+1)) * mult;
      mult++;
    }
    digit = soma % 11;
    if (digit == 0)
      result = String.valueOf(0);
    else {
      digit = 11 - digit;
      result = String.valueOf(digit);
    }
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant