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

Refatoração da geração do DV do titulo de eleitor #303

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -179,24 +179,28 @@ private String calculaDigitos(String tituloSemDigito) {
return digito1 + digito2;
}

private String geraDigito(boolean ehEstadoSubstitutorDigito, String base) {
private String geraDigito(boolean ehEstadoSubstitutorDigito, String base) {

String digito = new DigitoPara(base).mod(11).calcula();

if (ehEstadoSubstitutorDigito) {
if (digito.equals("1")) {
digito = "0";
} else if (digito.equals("0")) {
digito = "1";
} else {
digito = new DigitoPara(base).complementarAoModulo().mod(11).calcula();
if (!ehEstadoSubstitutorDigito) {

if (digito.equals("1") || digito.equals("0")) {
return "0";
}
} else {
digito = digito.equals("1") || digito.equals("0") ? "0" :
new DigitoPara(base).complementarAoModulo().mod(11).calcula();
}

return new DigitoPara(base).complementarAoModulo().mod(11).calcula();
}

return digito;
if (digito.equals("1")) {
return "0";
}

if (digito.equals("0")) {
return "1";
}

return new DigitoPara(base).complementarAoModulo().mod(11).calcula();
}

private boolean hasCodigoDeEstadoInvalido(String tituloDeEleitor) {
Expand Down