diff --git a/pom.xml b/pom.xml
index c30dd0e6e..ba84504b7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
4.0.0
br.com.rjconsultores
ventaboletosadm
- 1.0.64
+ 1.0.65
war
diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioBoletos.java b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioBoletos.java
index 28e35591c..6c5c6b5cc 100644
--- a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioBoletos.java
+++ b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioBoletos.java
@@ -18,7 +18,7 @@ import com.rjconsultores.ventaboletos.web.utilerias.NamedParameterStatement;
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
public class RelatorioBoletos extends Relatorio {
-
+
private static Logger log = Logger.getLogger(RelatorioBoletos.class);
private List lsDadosRelatorio;
@@ -35,33 +35,33 @@ public class RelatorioBoletos extends Relatorio {
Map parametros = this.relatorio.getParametros();
- Integer puntoventaId = parametros.get("puntoventaId") != null ? Integer.parseInt(parametros.get("puntoventaId").toString()) : null;
- Integer empresaId = parametros.get("empresaId") != null ? Integer.parseInt(parametros.get("empresaId").toString()) : null;
+ Integer puntoventaId = parametros.get(PUNTOVENTA_ID) != null ? Integer.parseInt(parametros.get(PUNTOVENTA_ID).toString()) : null;
+ Integer empresaId = parametros.get(EMPRESA_ID) != null ? Integer.parseInt(parametros.get(EMPRESA_ID).toString()) : null;
Boolean filtrarPendentes = parametros.get("filtrarPendentes") != null ? Boolean.parseBoolean(parametros.get("filtrarPendentes").toString()) : false;
- String fecInicio = parametros.get("fecInicio") != null ? parametros.get("fecInicio").toString() + " 00:00:00" :null;
- String fecFinal = parametros.get("fecFinal") != null ? parametros.get("fecFinal").toString() + " 23:59:59" :null;
- String baixaInicial = parametros.get("baixaInicial") != null ? parametros.get("baixaInicial").toString() + " 00:00:00" :null;
- String baixaFinal = parametros.get("baixaFinal") != null ? parametros.get("baixaFinal").toString() + " 23:59:59" :null;
+ String fecInicio = parametros.get(FEC_INICIO) != null ? parametros.get(FEC_INICIO).toString() + " 00:00:00" :null;
+ String fecFinal = parametros.get(FEC_FINAL) != null ? parametros.get(FEC_FINAL).toString() + " 23:59:59" :null;
+ String baixaInicial = parametros.get(BAIXA_INICIAL) != null ? parametros.get(BAIXA_INICIAL).toString() + " 00:00:00" :null;
+ String baixaFinal = parametros.get(BAIXA_FINAL) != null ? parametros.get(BAIXA_FINAL).toString() + " 23:59:59" :null;
String sql = getSQL(puntoventaId, empresaId, filtrarPendentes, fecInicio, fecFinal, baixaInicial, baixaFinal);
NamedParameterStatement stmt = new NamedParameterStatement(conexao, sql);
if(fecInicio != null && fecFinal != null) {
- stmt.setTimestamp("fecInicio", DateUtil.getTimestampFromString(fecInicio, DateUtil.ddMMaaHH24mmss));
- stmt.setTimestamp("fecFinal", DateUtil.getTimestampFromString(fecFinal, DateUtil.ddMMaaHH24mmss));
+ stmt.setTimestamp(FEC_INICIO, DateUtil.getTimestampFromString(fecInicio, DateUtil.ddMMaaHH24mmss));
+ stmt.setTimestamp(FEC_FINAL, DateUtil.getTimestampFromString(fecFinal, DateUtil.ddMMaaHH24mmss));
}
if(baixaInicial != null && baixaFinal != null) {
- stmt.setTimestamp("baixaInicial", DateUtil.getTimestampFromString(baixaInicial, DateUtil.ddMMaaHH24mmss));
- stmt.setTimestamp("baixaFinal", DateUtil.getTimestampFromString(baixaFinal, DateUtil.ddMMaaHH24mmss));
+ stmt.setTimestamp(BAIXA_INICIAL, DateUtil.getTimestampFromString(baixaInicial, DateUtil.ddMMaaHH24mmss));
+ stmt.setTimestamp(BAIXA_FINAL, DateUtil.getTimestampFromString(baixaFinal, DateUtil.ddMMaaHH24mmss));
}
- if(puntoventaId != null) {
- stmt.setInt("puntoventaId", puntoventaId);
+ if(puntoventaId != null && puntoventaId != -1) {
+ stmt.setInt(PUNTOVENTA_ID, puntoventaId);
}
if(empresaId != null) {
- stmt.setInt("empresaId", empresaId);
+ stmt.setInt(EMPRESA_ID, empresaId);
}
ResultSet rs = stmt.executeQuery();
@@ -87,50 +87,12 @@ public class RelatorioBoletos extends Relatorio {
boleto.setVrpendente(BigDecimal.ZERO);
}else {
boleto.setVrpendente(boleto.getVrboleto());
- }
-/*
- if (! filtrarPendentes){
-
- }
-
- boolean isPontoVendaEmpresaDiferente = (puntoventaIdAux == null || !puntoventaIdAux.equals(deposito.getPuntoventaId())) ||
- (empresaIdAux == null || !empresaIdAux.equals(deposito.getEmpresaId()));
-
- if(fechamentocntcorrenteId == null) {
- fechamentocntcorrenteId = rs.getLong("fechamentocntcorrenteId");
- } if(!isPontoVendaEmpresaDiferente && dtMotivo != null && DateUtil.compareOnlyDate(dtMotivo, deposito.getDtmotivo()) == 0 && !fechamentocntcorrenteId.equals(rs.getLong("fechamentocntcorrenteId"))) {
- pendente = deposito.getVrfechamento();
- totalFechamento = totalFechamento.add(deposito.getVrfechamento());
- fechamentocntcorrenteId = rs.getLong("fechamentocntcorrenteId");
- }
-
- if(isPontoVendaEmpresaDiferente || (dtMotivo == null || DateUtil.compareOnlyDate(dtMotivo, deposito.getDtmotivo()) != 0)) {
-
- if(isPontoVendaEmpresaDiferente) {
- puntoventaIdAux = deposito.getPuntoventaId();
- empresaIdAux = deposito.getEmpresaId();
- pendente = deposito.getVrfechamento();
- dtMotivo = deposito.getDtmotivo();
- totalFechamento = totalFechamento.add(deposito.getVrfechamento());
- fechamentocntcorrenteId = rs.getLong("fechamentocntcorrenteId");
- }
-
- if(dtMotivo == null || DateUtil.compareOnlyDate(dtMotivo, deposito.getDtmotivo()) != 0) {
- pendente = deposito.getVrfechamento();
- totalFechamento = totalFechamento.add(deposito.getVrfechamento());
- fechamentocntcorrenteId = rs.getLong("fechamentocntcorrenteId");
- }
- dtMotivo = deposito.getDtmotivo();
- }
-
- pendente = pendente.subtract(deposito.getVrdeposito());
- deposito.setVrpendente(pendente);
-*/
+ }
lsDadosRelatorio.add(boleto);
}
- if (lsDadosRelatorio.size() > 0) {
+ if (!lsDadosRelatorio.isEmpty()) {
setLsDadosRelatorio(lsDadosRelatorio);
}
@@ -190,7 +152,7 @@ public class RelatorioBoletos extends Relatorio {
sql.append(" AND fb.fecbaixa BETWEEN :baixaInicial AND :baixaFinal ");
}
- if(puntoventaId != null) {
+ if(puntoventaId != null && puntoventaId != -1) {
sql.append(" AND fcc.puntoventa_id = :puntoventaId ");
}
diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioDepositos.java b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioDepositos.java
index 82fa35d22..8b29c878f 100644
--- a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioDepositos.java
+++ b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioDepositos.java
@@ -2,9 +2,7 @@ package com.rjconsultores.ventaboletos.relatorios.impl;
import java.math.BigDecimal;
import java.sql.Connection;
-import java.sql.PreparedStatement;
import java.sql.ResultSet;
-import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -16,11 +14,12 @@ import com.rjconsultores.ventaboletos.relatorios.utilitarios.DataSource;
import com.rjconsultores.ventaboletos.relatorios.utilitarios.Relatorio;
import com.rjconsultores.ventaboletos.relatorios.utilitarios.RelatorioDepositoBean;
import com.rjconsultores.ventaboletos.utilerias.DateUtil;
+import com.rjconsultores.ventaboletos.web.utilerias.NamedParameterStatement;
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
public class RelatorioDepositos extends Relatorio {
-
+
private static Logger log = Logger.getLogger(RelatorioDepositos.class);
private List lsDadosRelatorio;
@@ -37,26 +36,31 @@ public class RelatorioDepositos extends Relatorio {
Map parametros = this.relatorio.getParametros();
- Integer puntoventaId = parametros.get("puntoventaId") != null ? Integer.parseInt(parametros.get("puntoventaId").toString()) : null;
- Integer empresaId = parametros.get("empresaId") != null ? Integer.parseInt(parametros.get("empresaId").toString()) : null;
- Boolean filtrarPendentes = parametros.get("filtrarPendentes") != null ? Boolean.parseBoolean(parametros.get("filtrarPendentes").toString()) : false;
- String fecInicio = parametros.get("fecInicio").toString() + " 00:00:00";
- String fecFinal = parametros.get("fecFinal").toString() + " 23:59:59";
+ Integer puntoventaId = parametros.get(PUNTOVENTA_ID) != null ? Integer.parseInt(parametros.get(PUNTOVENTA_ID).toString()) : null;
+ Integer empresaId = parametros.get(EMPRESA_ID) != null ? Integer.parseInt(parametros.get(EMPRESA_ID).toString()) : null;
+ boolean filtrarPendentes = parametros.get("filtrarPendentes") != null ? Boolean.parseBoolean(parametros.get("filtrarPendentes").toString()) : false;
+ String fecInicio = parametros.get(FEC_INICIO).toString() + " 00:00:00";
+ String fecFinal = parametros.get(FEC_FINAL).toString() + " 23:59:59";
String sql = getSQL(puntoventaId, empresaId, filtrarPendentes);
- PreparedStatement stmt = conexao.prepareStatement(sql);
-
- ResultSet rs = null;
- SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss");
+ NamedParameterStatement stmt = new NamedParameterStatement(conexao, sql);
- stmt.setTimestamp(1, new java.sql.Timestamp(sdf.parse(fecInicio).getTime()));
- stmt.setTimestamp(2, new java.sql.Timestamp(sdf.parse(fecFinal).getTime()));
+ stmt.setTimestamp(FEC_INICIO, DateUtil.getTimestampFromString(fecInicio, DateUtil.ddMMaaHH24mmss));
+ stmt.setTimestamp(FEC_FINAL, DateUtil.getTimestampFromString(fecFinal, DateUtil.ddMMaaHH24mmss));
- rs = stmt.executeQuery();
+ if(puntoventaId != null && puntoventaId != -1) {
+ stmt.setInt(PUNTOVENTA_ID, puntoventaId);
+ }
+
+ if(empresaId != null) {
+ stmt.setInt(EMPRESA_ID, empresaId);
+ }
+
+ ResultSet rs = stmt.executeQuery();
rs.setFetchSize(500);
- lsDadosRelatorio = new ArrayList();
+ lsDadosRelatorio = new ArrayList<>();
Integer puntoventaIdAux = null;
Integer empresaIdAux = null;
@@ -74,10 +78,9 @@ public class RelatorioDepositos extends Relatorio {
deposito.setSaldo(rs.getBigDecimal("saldo").multiply(BigDecimal.valueOf(-1)));
deposito.setVrdeposito(rs.getBigDecimal("vlrBoletoDeposito"));
deposito.setVrfechamento(rs.getBigDecimal("vrfechamento"));
- deposito.setEmpresaId(rs.getInt("empresaId"));
- deposito.setPuntoventaId(rs.getInt("puntoventaId"));
-
-
+ deposito.setEmpresaId(rs.getInt(EMPRESA_ID));
+ deposito.setPuntoventaId(rs.getInt(PUNTOVENTA_ID));
+
if (! filtrarPendentes){
deposito.setNumdeposito(rs.getString("numdeposito"));
}
@@ -86,11 +89,11 @@ public class RelatorioDepositos extends Relatorio {
(empresaIdAux == null || !empresaIdAux.equals(deposito.getEmpresaId()));
if(fechamentocntcorrenteId == null) {
- fechamentocntcorrenteId = rs.getLong("fechamentocntcorrenteId");
- } if(!isPontoVendaEmpresaDiferente && dtMotivo != null && DateUtil.compareOnlyDate(dtMotivo, deposito.getDtmotivo()) == 0 && !fechamentocntcorrenteId.equals(rs.getLong("fechamentocntcorrenteId"))) {
+ fechamentocntcorrenteId = rs.getLong(FECHAMENTOCNTCORRENTE_ID);
+ } if(!isPontoVendaEmpresaDiferente && dtMotivo != null && DateUtil.compareOnlyDate(dtMotivo, deposito.getDtmotivo()) == 0 && !fechamentocntcorrenteId.equals(rs.getLong(FECHAMENTOCNTCORRENTE_ID))) {
pendente = deposito.getVrfechamento();
totalFechamento = totalFechamento.add(deposito.getVrfechamento());
- fechamentocntcorrenteId = rs.getLong("fechamentocntcorrenteId");
+ fechamentocntcorrenteId = rs.getLong(FECHAMENTOCNTCORRENTE_ID);
}
if(isPontoVendaEmpresaDiferente || (dtMotivo == null || DateUtil.compareOnlyDate(dtMotivo, deposito.getDtmotivo()) != 0)) {
@@ -101,13 +104,13 @@ public class RelatorioDepositos extends Relatorio {
pendente = deposito.getVrfechamento();
dtMotivo = deposito.getDtmotivo();
totalFechamento = totalFechamento.add(deposito.getVrfechamento());
- fechamentocntcorrenteId = rs.getLong("fechamentocntcorrenteId");
+ fechamentocntcorrenteId = rs.getLong(FECHAMENTOCNTCORRENTE_ID);
}
if(dtMotivo == null || DateUtil.compareOnlyDate(dtMotivo, deposito.getDtmotivo()) != 0) {
pendente = deposito.getVrfechamento();
totalFechamento = totalFechamento.add(deposito.getVrfechamento());
- fechamentocntcorrenteId = rs.getLong("fechamentocntcorrenteId");
+ fechamentocntcorrenteId = rs.getLong(FECHAMENTOCNTCORRENTE_ID);
}
dtMotivo = deposito.getDtmotivo();
}
@@ -118,7 +121,7 @@ public class RelatorioDepositos extends Relatorio {
lsDadosRelatorio.add(deposito);
}
- if (lsDadosRelatorio.size() > 0) {
+ if (!lsDadosRelatorio.isEmpty()) {
setLsDadosRelatorio(lsDadosRelatorio);
}
parametros.put("totalFechamento", totalFechamento);
@@ -137,7 +140,8 @@ public class RelatorioDepositos extends Relatorio {
}
@Override
- protected void processaParametros() throws Exception {
+ protected void processaParametros() throws Exception {
+ // TODO document why this method is empty
}
private String getSQL(Integer puntoVentaId, Integer empresaId, boolean filtrarPendentes) {
@@ -165,10 +169,10 @@ public class RelatorioDepositos extends Relatorio {
sql.append(" p.numpuntoventa, ");
sql.append(" p.puntoventa_id as puntoventaId, ");
sql.append(" e.empresa_id as empresaId, ");
- sql.append(" f.fecfechamento AS dtmotivo, ");
- sql.append(" ( SUM(COALESCE(fd.valor_pago,fbol.valordocumento,0)) - f.total ) AS saldo, ");
- sql.append(" SUM(COALESCE(fd.valor_pago,fbol.valordocumento,0)) AS vlrBoletoDeposito, ");
- sql.append(" f.total AS vrfechamento, ");
+ sql.append(" f.fecfechamento as dtmotivo, ");
+ sql.append(" ( SUM(COALESCE(fd.valor_pago,0)) - f.total ) AS saldo, ");
+ sql.append(" SUM(COALESCE(fd.valor_pago,0)) AS vlrBoletoDeposito, ");
+ sql.append(" f.total as vrfechamento, ");
if (! filtrarPendentes){
sql.append(" fdp.NUMDEPOSITO as numdeposito, ");
@@ -178,8 +182,10 @@ public class RelatorioDepositos extends Relatorio {
sql.append(" FROM fechamento_cntcorrente f ");
sql.append(" INNER JOIN punto_venta p ");
sql.append(" ON p.puntoventa_id = f.puntoventa_id ");
+ sql.append(" AND p.activo = 1 ");
sql.append(" INNER JOIN empresa e ");
sql.append(" ON e.empresa_id = f.empresa_id ");
+ sql.append(" AND e.activo = 1 ");
sql.append(" INNER JOIN fechamento_boleto fbol ");
sql.append(" ON f.fechamentocntcorrente_id = fbol.fechamentocntcorrente_id ");
sql.append(" AND fbol.tipo_pagamento = 'D' ");
@@ -190,16 +196,15 @@ public class RelatorioDepositos extends Relatorio {
sql.append(" LEFT JOIN FECHAMENTO_DEPOSITO fdp ");
sql.append(" ON fdp.FECHAMENTODEPOSITO_ID = fd.FECHAMENTODEPOSITO_ID ");
sql.append(" AND fdp.activo = 1 ");
- sql.append(" WHERE f.fecfechamento BETWEEN ? AND ? ");
+ sql.append(" WHERE f.fecfechamento BETWEEN :fecInicio AND :fecFinal ");
sql.append(" AND f.activo = 1 ");
- sql.append(" AND e.activo = 1 ");
- sql.append(" AND p.activo = 1 ");
- if (puntoVentaId != null && puntoVentaId != -1){
- sql.append(" and f.puntoventa_id = " + puntoVentaId);
+ if(puntoVentaId != null && puntoVentaId != -1) {
+ sql.append(" AND f.puntoventa_id = :puntoventaId ");
}
- if (empresaId != null && empresaId != -1){
- sql.append(" and e.empresa_id = " + empresaId);
+
+ if(empresaId != null) {
+ sql.append(" AND e.empresa_id = :empresaId ");
}
sql.append(" GROUP BY e.nombempresa, ");
sql.append(" p.nombpuntoventa, ");
diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/utilitarios/Relatorio.java b/src/java/com/rjconsultores/ventaboletos/relatorios/utilitarios/Relatorio.java
index ff0dd4166..1467afae4 100644
--- a/src/java/com/rjconsultores/ventaboletos/relatorios/utilitarios/Relatorio.java
+++ b/src/java/com/rjconsultores/ventaboletos/relatorios/utilitarios/Relatorio.java
@@ -20,6 +20,14 @@ public abstract class Relatorio {
private static Logger log = Logger.getLogger(Relatorio.class);
private static final String DEFAULT_BASE_DIR = "/com/rjconsultores/ventaboletos/relatorios";
private static final String FILTRO_POR_TODOS = "-1";
+
+ protected static final String BAIXA_FINAL = "baixaFinal";
+ protected static final String BAIXA_INICIAL = "baixaInicial";
+ protected static final String FEC_FINAL = "fecFinal";
+ protected static final String FEC_INICIO = "fecInicio";
+ protected static final String EMPRESA_ID = "empresaId";
+ protected static final String PUNTOVENTA_ID = "puntoventaId";
+ protected static final String FECHAMENTOCNTCORRENTE_ID = "fechamentocntcorrenteId";
private Connection conexao;
protected Map parametros;