diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioAgenciaFechamento.java b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioAgenciaFechamento.java index d8883ef4c..280cb685a 100644 --- a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioAgenciaFechamento.java +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioAgenciaFechamento.java @@ -98,13 +98,15 @@ public abstract class RelatorioAgenciaFechamento extends Relatorio { * @throws ParseException */ protected void carregarDadosTotaisVenda(String fecInicio, String fecFinal, String empresa, String empresaNome, String puntoVenta) throws SQLException, ParseException { - + boolean isDiario = TipoRelatorioFechamentoEnum.DIARIO.equals(tipoRelatorio); NamedParameterStatement stmt = new NamedParameterStatement(getConexao(), criarQueryBilhetesVenda(puntoVenta, empresa)); - SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss") , sdf2 = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); + SimpleDateFormat sdf = (isDiario ? new SimpleDateFormat("yyyy-MM-dd hh:mm:ss") : new SimpleDateFormat("dd/MM/yyyy hh:mm:ss") ); ResultSet rset1 = criaResultSet(fecInicio, fecFinal, sdf, stmt); - + String dataInicial = fecInicio; + String dataFinal = fecFinal; + StringBuilder puntoVentaIds = new StringBuilder(); puntoVentaIds.append(" 0"); @@ -121,9 +123,11 @@ public abstract class RelatorioAgenciaFechamento extends Relatorio { Integer qtdedigitado = rset1.getInt("qtdedigitado"); Integer qtdeAnulado = rset1.getInt("qtdeAnulado"); Integer qtdeDevolvido = rset1.getInt("qtdeDevolvido"); - String dataInicial = rset1.getString("DATA"); - String dataFinal = rset1.getString("DATA"); - + + if (isDiario) { + dataInicial = rset1.getString("DATA"); + dataFinal = rset1.getString("DATA"); + } vendido = rset1.getBigDecimal("vendido"); BigDecimal digitado = rset1.getBigDecimal("digitado"); @@ -132,7 +136,7 @@ public abstract class RelatorioAgenciaFechamento extends Relatorio { total = preencherAgenciaFechamento(empresaNome, rset1, agenciaFechamento, total, vendido, qtdevendido, qtdedigitado, qtdeAnulado, qtdeDevolvido, digitado, anulado, devolvido); - carregarDadosReceitaDespesa(dataInicial, dataFinal, empresa, sdf2, agenciaFechamento, total, vendido, puntoVentaId); + carregarDadosReceitaDespesa(dataInicial, dataFinal, isDiario, empresa, sdf, agenciaFechamento, total, vendido, puntoVentaId); lsDadosRelatorio.add(agenciaFechamento); } @@ -158,11 +162,13 @@ public abstract class RelatorioAgenciaFechamento extends Relatorio { * @throws SQLException * @throws ParseException */ - protected void carregarDadosReceitaDespesa(String fecInicio, String fecFinal, String empresa, SimpleDateFormat sdf, RelatorioAgenciaFechamentoAntigoBean agenciaFechamento, BigDecimal total, BigDecimal vendido, String puntoVentaId) throws SQLException, ParseException { + protected void carregarDadosReceitaDespesa(String fecInicio, String fecFinal, Boolean isDiario, String empresa, SimpleDateFormat sdf, RelatorioAgenciaFechamentoAntigoBean agenciaFechamento, BigDecimal total, BigDecimal vendido, String puntoVentaId) throws SQLException, ParseException { NamedParameterStatement stmt = new NamedParameterStatement(getConexao(), criarQueryReceitaDespesa(puntoVentaId, empresa)); + if (isDiario) { + fecInicio = fecInicio.substring(0, 10).toString() + " 00:00:00"; + fecFinal = fecFinal.substring(0, 10).toString() + " 23:59:59"; + } - fecInicio = fecInicio.substring(0, 10).toString() + " 00:00:00"; - fecFinal = fecFinal.substring(0, 10).toString() + " 23:59:59"; stmt.setTimestamp("de", new java.sql.Timestamp(sdf.parse(fecInicio).getTime())); stmt.setTimestamp("ate", new java.sql.Timestamp(sdf.parse(fecFinal).getTime()));