fixes bug#AL-4941

master
Gleison da Cruz 2024-09-18 15:39:05 -03:00
parent cdfee6516b
commit 0b2afa0f33
2 changed files with 47 additions and 7 deletions

View File

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>br.com.rjconsultores</groupId> <groupId>br.com.rjconsultores</groupId>
<artifactId>ModelWeb</artifactId> <artifactId>ModelWeb</artifactId>
<version>1.108.1</version> <version>1.108.2</version>
<distributionManagement> <distributionManagement>
<repository> <repository>

View File

@ -8,6 +8,7 @@ import java.math.BigDecimal;
import java.math.BigInteger; import java.math.BigInteger;
import java.sql.SQLException; import java.sql.SQLException;
import org.apache.commons.lang.StringUtils;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -218,6 +219,7 @@ public class ImportacaoRetornoBancarioServiceImpl implements ImportacaoRetornoBa
FechamentoBoleto boleto = remessaCNABBancosDAO.obtenerFechamentoBoletoPorNossoNumero(detalhe.getNossoNumero(), FechamentoBoleto boleto = remessaCNABBancosDAO.obtenerFechamentoBoletoPorNossoNumero(detalhe.getNossoNumero(),
empresaId); empresaId);
//18/09/2024 Apos um ano e meio excluir este trecho
if (boleto == null) { if (boleto == null) {
if (detalhe instanceof DetalheRetornoItau) { if (detalhe instanceof DetalheRetornoItau) {
return validaDacItau(detalhe, empresaId, usuarioId); return validaDacItau(detalhe, empresaId, usuarioId);
@ -257,19 +259,21 @@ public class ImportacaoRetornoBancarioServiceImpl implements ImportacaoRetornoBa
} }
//18/09/2024 Apos um ano e meio excluir este metodo
public boolean validaDacItau(DetalheRetorno detalhe, Integer empresaId, Integer usuarioId) throws SQLException { public boolean validaDacItau(DetalheRetorno detalhe, Integer empresaId, Integer usuarioId) throws SQLException {
FechamentoParamgeral dadosContaItau = fechamentoParamgeralService.buscaParametrosPorEmpresasBanco(empresaId, "341"); FechamentoParamgeral dadosContaItau = fechamentoParamgeralService.buscaParametrosPorEmpresasBanco(empresaId, "341");
BigInteger nossoNumero = new BigInteger(detalhe.getNossoNumero().substring(0, 7)); BigInteger nossoNumero = new BigInteger(detalhe.getNossoNumero().substring(0, 8));
if (dadosContaItau != null) { if (dadosContaItau != null) {
String dacItau = NossoNumeroUtils.dacItau( String dacItauAntigo = dacItauAntigo(
Integer.valueOf(dadosContaItau.getBoletoBancoAgencia()), Integer.valueOf(dadosContaItau.getBoletoBancoAgencia()),
Integer.valueOf(dadosContaItau.getBoletoBancoConta()), Integer.valueOf(dadosContaItau.getBoletoBancoConta()),
Integer.valueOf(dadosContaItau.getBoletoBancoCarteira()), Integer.valueOf(dadosContaItau.getBoletoBancoCarteira()),
nossoNumero); nossoNumero);
detalhe.setNossoNumero(detalhe.getNossoNumero().substring(0, 7) + "-" + dacItau); detalhe.setNossoNumero(detalhe.getNossoNumero().substring(0, 8) + "-" + dacItauAntigo);
FechamentoBoleto boleto = remessaCNABBancosDAO.obtenerFechamentoBoletoPorNossoNumero(detalhe.getNossoNumero(), FechamentoBoleto boleto = remessaCNABBancosDAO.obtenerFechamentoBoletoPorNossoNumero(detalhe.getNossoNumero(),
empresaId); empresaId);
@ -286,4 +290,40 @@ public class ImportacaoRetornoBancarioServiceImpl implements ImportacaoRetornoBa
}else }else
throw new RuntimeException("Dados da conta não encontrados : " + detalhe.getIdBoletoFechamento()); throw new RuntimeException("Dados da conta não encontrados : " + detalhe.getIdBoletoFechamento());
} }
//18/09/2024 Apos um ano e meio excluir este metodo
public static String dacItauAntigo(Integer codAgencia, Integer numConta, Integer numCarteira, BigInteger nossoNumero){
int multiplicadores[] = {2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1};
int multiplicandos[] = new int[20];
String agencia = StringUtils.right("0000" + codAgencia, 4);
String conta = StringUtils.right("00000" + numConta, 5);
String carteira = StringUtils.right("000" + numCarteira, 3);
String nNumero = StringUtils.right("00000000" + nossoNumero, 8);
String base = agencia + conta + carteira + nNumero;
for (int i = 0; i < multiplicandos.length; i++) {
String d = base.charAt(i) + "";
multiplicandos[i] = Integer.valueOf(d) * multiplicadores[i];
}
int dac = 0;
for(Integer v : multiplicandos){
if(v < 10){
dac += v;
}else{
dac += 1 + (v - 10);
}
}
dac = 10 - (dac % 10);
return dac == 10 ? "0" : dac+"";
}
} }