Skip to content

Commit

Permalink
fix: unnecessary if
Browse files Browse the repository at this point in the history
  • Loading branch information
edniemeyer committed Apr 29, 2020
1 parent a873c9e commit 3a601f5
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/boleto-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ exports.identificarTipoBoleto = (codigo) => {
codigo = codigo.replace(/[^0-9]/g, '');

if (typeof codigo !== 'string') throw new TypeError('Insira uma string válida!');
if (codigo.substr(-14) == '00000000000000' || codigo.substr(5,14) == '00000000000000') {

if (codigo.substr(-14) == '00000000000000' || codigo.substr(5, 14) == '00000000000000') {
return 'CARTAO_DE_CREDITO';
} else if (codigo.substr(0, 1) == '8') {
if (codigo.substr(1, 1) == '1') {
Expand All @@ -65,7 +65,7 @@ exports.identificarTipoBoleto = (codigo) => {
return 'OUTROS';
} else if (codigo.substr(1, 1) == '7') {
return 'ARRECADACAO_TAXAS_DE_TRANSITO';
}
}
} else {
return 'BANCO';
}
Expand Down Expand Up @@ -420,11 +420,7 @@ exports.calculaDVCodBarras = (codigo, posicaoCodigo, mod) => {
if (mod === 10) {
return this.calculaMod10(codigo);
} else if (mod === 11) {
if (posicaoCodigo === 4) {// tipoBoleto BANCO ou CARTAO_DE_CREDITO
return this.calculaMod11(codigo);
} else if(posicaoCodigo === 3) {// tipoBoleto diferente de BANCO ou CARTAO_DE_CREDITO
return this.calculaMod11(codigo);
}
return this.calculaMod11(codigo);
}
}

Expand Down Expand Up @@ -750,7 +746,7 @@ exports.calculaMod11 = (x) => {

DAC = digit % 11;

if (DAC== 0 || DAC == 1)
if (DAC == 0 || DAC == 1)
return 0;
if (DAC == 10)
return 1;
Expand Down

0 comments on commit 3a601f5

Please sign in to comment.