diff --git a/pom.xml b/pom.xml
index 7254173da..8c2ad0dbe 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
4.0.0
br.com.rjconsultores
ModelWeb
- 1.108.1
+ 1.108.2
diff --git a/src/com/rjconsultores/ventaboletos/service/impl/ImportacaoRetornoBancarioServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/ImportacaoRetornoBancarioServiceImpl.java
index 022ea8407..89d92ee47 100644
--- a/src/com/rjconsultores/ventaboletos/service/impl/ImportacaoRetornoBancarioServiceImpl.java
+++ b/src/com/rjconsultores/ventaboletos/service/impl/ImportacaoRetornoBancarioServiceImpl.java
@@ -8,6 +8,7 @@ import java.math.BigDecimal;
import java.math.BigInteger;
import java.sql.SQLException;
+import org.apache.commons.lang.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
@@ -218,8 +219,9 @@ public class ImportacaoRetornoBancarioServiceImpl implements ImportacaoRetornoBa
FechamentoBoleto boleto = remessaCNABBancosDAO.obtenerFechamentoBoletoPorNossoNumero(detalhe.getNossoNumero(),
empresaId);
- if (boleto == null) {
- if (detalhe instanceof DetalheRetornoItau) {
+ //18/09/2024 Apos um ano e meio excluir este trecho
+ if (boleto == null) {
+ if (detalhe instanceof DetalheRetornoItau) {
return validaDacItau(detalhe, empresaId, usuarioId);
} else {
throw new RuntimeException(
@@ -257,19 +259,21 @@ public class ImportacaoRetornoBancarioServiceImpl implements ImportacaoRetornoBa
}
- public boolean validaDacItau(DetalheRetorno detalhe, Integer empresaId, Integer usuarioId) throws SQLException {
+ //18/09/2024 Apos um ano e meio excluir este metodo
+ public boolean validaDacItau(DetalheRetorno detalhe, Integer empresaId, Integer usuarioId) throws SQLException {
+
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) {
- String dacItau = NossoNumeroUtils.dacItau(
+ String dacItauAntigo = dacItauAntigo(
Integer.valueOf(dadosContaItau.getBoletoBancoAgencia()),
Integer.valueOf(dadosContaItau.getBoletoBancoConta()),
Integer.valueOf(dadosContaItau.getBoletoBancoCarteira()),
nossoNumero);
- detalhe.setNossoNumero(detalhe.getNossoNumero().substring(0, 7) + "-" + dacItau);
+ detalhe.setNossoNumero(detalhe.getNossoNumero().substring(0, 8) + "-" + dacItauAntigo);
FechamentoBoleto boleto = remessaCNABBancosDAO.obtenerFechamentoBoletoPorNossoNumero(detalhe.getNossoNumero(),
empresaId);
@@ -286,4 +290,40 @@ public class ImportacaoRetornoBancarioServiceImpl implements ImportacaoRetornoBa
}else
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+"";
+ }
}