Merge pull request 'fixes bug#AL-4419' (#14) from AL-4419 into master

Reviewed-on: adm/IntegracaoReceitaDespesa#14
Reviewed-by: Célio de Souza Ribeiro JR <celio@rjconsultores.com.br>
master
Gleison da Cruz 2024-06-20 11:39:39 +00:00
commit 807bebb3ec
2 changed files with 38 additions and 5 deletions

View File

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>br.com.rjconsultores</groupId>
<artifactId>IntegracaoReceitaDespesa</artifactId>
<version>1.5.0</version>
<version>1.6.0</version>
<distributionManagement>
<repository>

View File

@ -28,6 +28,7 @@ public class Totalbus {
private static final Logger log = LogManager.getLogger(Totalbus.class);
private static final int DAYS_AGO = -1;
private Connection conn;
private List<PuntoVenta> pontosVenda = new ArrayList<PuntoVenta>();
@ -43,12 +44,15 @@ public class Totalbus {
private DecimalFormat df = new DecimalFormat("#0.00");
private int formaPagoCieloLink = 0;
public Totalbus(Connection con, Boolean isReceitasDespesasComporte, Boolean isReceitasDespesasOuroPrata) {
this.conn = con;
this.isReceitasDespesasComporte = isReceitasDespesasComporte;
this.isReceitasDespesasOuroPrata = isReceitasDespesasOuroPrata;
loadEmpresas();
loadPuntosVenta();
buscarFormaPagoCieloLink();
}
public Totalbus(Connection con, Boolean isReceitasDespesasComporte,Boolean isCodReceitaFixoBgm, Boolean isReceitasDespesasOuroPrata) {
@ -58,6 +62,7 @@ public class Totalbus {
this.isCodReceitaFixoBgm = isCodReceitaFixoBgm;
loadEmpresas();
loadPuntosVenta();
buscarFormaPagoCieloLink();
}
public Totalbus(Connection con, Boolean isReceitasDespesasComporte,Boolean isCodReceitaFixoBgm, Boolean isReceitasDespesasOuroPrata, Boolean isLayoutNovo) {
@ -68,6 +73,7 @@ public class Totalbus {
this.isLayoutNovo = isLayoutNovo;
loadEmpresas();
loadPuntosVenta();
buscarFormaPagoCieloLink();
}
public List<String> getDespesasReceitas(Integer puntoventaId, Integer empresaId, Date fechaParam, boolean incluiTipoPagamentoTurismoBGM, boolean isLayoutNovo) throws IntegracaoReceitaDespesaException{
@ -560,6 +566,7 @@ public class Totalbus {
}
public List<DespesaReceitaComporte> getDespesaCartaoDebCredComporte(final Integer puntoVentaId, final Integer empresaId, Date fechaParam, boolean incluiTipoPagamentoTurismoBGM) throws IntegracaoReceitaDespesaException{
List<DespesaReceitaComporte> despesas = new ArrayList<DespesaReceitaComporte>();
StringBuilder sb = new StringBuilder();
sb.append(" select ");
@ -592,7 +599,7 @@ public class Totalbus {
adicionaFiltroQuery(puntoVentaId, sb, " and cd.puntoventa_id = ", puntoVentaId != null && !puntoVentaId.equals(-1));
adicionaFiltroQuery(empresaId, sb, " and e.empresa_id = ", empresaId != null);
sb.append(" and cd.activo = 1 ");
sb.append(" and cdp.formapago_id in (2,3) ");
sb.append(" and cdp.formapago_id in (2,3," +formaPagoCieloLink+ ") ");
sb.append(" and tee.indtipo = 0 ");
PreparedStatement stmt = null;
@ -632,7 +639,7 @@ public class Totalbus {
}
despesa.setFormaPagamentoId(rs.getString("formapagoId"));
if( despesa.getFormaPagamentoId().equals("2") || despesa.getFormaPagamentoId().equals("3")) {
if( despesa.getFormaPagamentoId().equals("2") || despesa.getFormaPagamentoId().equals("3") || despesa.getFormaPagamentoId().equals(formaPagoCieloLink)) {
despesa.setCodigoAutorizacao(rs.getString("numautorizacion"));
despesa.setNumeroEstabelecimento(rs.getString("numeroEstabelecimento"));
}else {
@ -1412,6 +1419,32 @@ public class Totalbus {
return despesas;
}
private void buscarFormaPagoCieloLink() {
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
pstmt = getConnection().prepareStatement("Select formapago_id from forma_pago where tipo_carteira_digital = 'CIELO_LINK' and activo = 1");
rs = pstmt.executeQuery();
if (rs.getFetchSize() > 0) {
while (rs.next()) {
formaPagoCieloLink = rs.getInt(1);
}
}
} catch (Exception e) {
log.error(e.getMessage(), e);
} finally {
try {
rs.close();
} catch (Exception ignore) {
log.error(ignore.getMessage(), ignore);
}
try {
pstmt.close();
} catch (Exception ignore) {
log.error(ignore.getMessage(), ignore);
}
}
}
}