diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioAgenciaFechamento.java b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioAgenciaFechamento.java index 46b5cf5a2..a024a5e80 100644 --- a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioAgenciaFechamento.java +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioAgenciaFechamento.java @@ -3,231 +3,65 @@ package com.rjconsultores.ventaboletos.relatorios.impl; import java.math.BigDecimal; import java.sql.Connection; import java.sql.ResultSet; +import java.sql.SQLException; +import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.List; import java.util.Map; import org.apache.commons.lang.math.NumberUtils; -import org.slf4j.Logger; -import com.rjconsultores.ventaboletos.relatorios.utilitarios.DataSource; import com.rjconsultores.ventaboletos.relatorios.utilitarios.Relatorio; -import com.rjconsultores.ventaboletos.relatorios.utilitarios.RelatorioAgenciaFechamentoBean; +import com.rjconsultores.ventaboletos.relatorios.utilitarios.RelatorioAgenciaFechamentoAntigoBean; import com.rjconsultores.ventaboletos.web.utilerias.NamedParameterStatement; import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource; -public class RelatorioAgenciaFechamento extends Relatorio { +public abstract class RelatorioAgenciaFechamento extends Relatorio { - private static Logger log = org.slf4j.LoggerFactory.getLogger(RelatorioAgenciaFechamento.class); - - private List lsDadosRelatorio; + protected List lsDadosRelatorio; + + protected TipoRelatorioFechamentoEnum tipoRelatorio; public RelatorioAgenciaFechamento(Map parametros, Connection conexao) throws Exception { super(parametros, conexao); - - this.setCustomDataSource(new DataSource(this) { - @Override - public void initDados() throws Exception { - - Connection conexao = this.relatorio.getConexao(); - - Map parametros = this.relatorio.getParametros(); - - String fecInicio = parametros.get("fecInicio").toString() + " 00:00:00"; - String fecFinal = parametros.get("fecFinal").toString() + " 23:59:59"; - String empresa = parametros.get("empresa") != null ? parametros.get("empresa").toString() : ""; - String empresaNome = parametros.get("empresaNome") != null ? parametros.get("empresaNome").toString() : ""; - String puntoVenta = parametros.get("NUMPUNTOVENTA") != null ? parametros.get("NUMPUNTOVENTA").toString() : null; - - lsDadosRelatorio = new ArrayList(); - - String sql = carregarDadosTotaisdeVenda(puntoVenta, empresa); - - log.debug(sql); - - NamedParameterStatement stmt = new NamedParameterStatement(conexao, sql); - ResultSet rset1 = null; - ResultSet rset2 = null; - SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss"); - - stmt.setTimestamp("de", new java.sql.Timestamp(sdf.parse(fecInicio).getTime())); - stmt.setTimestamp("ate", new java.sql.Timestamp(sdf.parse(fecFinal).getTime())); - - rset1= stmt.executeQuery(); - - while (rset1.next()) { - - Integer qtdExcesso = NumberUtils.INTEGER_ZERO; - Integer qtdSeguro = NumberUtils.INTEGER_ZERO; - - BigDecimal valorExcesso = BigDecimal.ZERO; - BigDecimal valorSeguro = BigDecimal.ZERO; - - RelatorioAgenciaFechamentoBean agenciaFechamento = new RelatorioAgenciaFechamentoBean(); - - agenciaFechamento.setEmpresa(empresaNome); - String puntoVentaId = rset1.getString("codigo"); - agenciaFechamento.setDescricao(rset1.getString("descricao")); - - agenciaFechamento.setValorBilhete(rset1.getBigDecimal("valorBilhete")); - agenciaFechamento.setValorVch(rset1.getBigDecimal("valorVch")); - agenciaFechamento.setValorInternet(rset1.getBigDecimal("valorInternet")); - agenciaFechamento.setValorCancelado(rset1.getBigDecimal("valorCancelado")); - agenciaFechamento.setValorEstornado(rset1.getBigDecimal("valorEstornado")); - valorSeguro = rset1.getBigDecimal("valorSeguro"); - - agenciaFechamento.setQtdBilhete(rset1.getInt("qtdBilhete")); - agenciaFechamento.setQtdVch(rset1.getInt("qtdVch")); - agenciaFechamento.setQtdInternet(rset1.getInt("qtdInternet")); - agenciaFechamento.setQtdCancelado(rset1.getInt("qtdCancelado")); - agenciaFechamento.setQtdEstornado(rset1.getInt("qtdEstornado")); - qtdSeguro = rset1.getInt("qtdSeguro"); - - String strQueryEventoExtra = carregarEventosExtras(puntoVentaId, empresa); - stmt = new NamedParameterStatement(conexao, strQueryEventoExtra); - - stmt.setTimestamp("de", new java.sql.Timestamp(sdf.parse(fecInicio).getTime())); - stmt.setTimestamp("ate", new java.sql.Timestamp(sdf.parse(fecFinal).getTime())); - - rset2 = stmt.executeQuery(); - - if (rset2.next()) { - - qtdSeguro += rset2.getInt("qtdSeguro"); - qtdExcesso = rset2.getInt("qtdExcesso"); - - valorSeguro = valorSeguro.add(rset2.getBigDecimal("valorSeguro")); - valorExcesso = valorExcesso.add(rset2.getBigDecimal("valorExcesso")); - } - - agenciaFechamento.setQtdExcesso(qtdExcesso); - agenciaFechamento.setQtdSeguro(qtdSeguro); - agenciaFechamento.setValorExcesso(valorExcesso); - agenciaFechamento.setValorSeguro(valorSeguro); - - lsDadosRelatorio.add(agenciaFechamento); - //Estava dando um erro de "máximo de cursores abertos excedido" - //Colocado isso o erro parou de ocorrer - rset2.getStatement().close(); - rset2.close(); - } - - rset1.close(); - - if (lsDadosRelatorio.size() > 0) { - setLsDadosRelatorio(lsDadosRelatorio); - } - - } - }); - } - - public void setLsDadosRelatorio(List lsDadosRelatorio) { - this.setCollectionDataSource(new JRBeanCollectionDataSource(lsDadosRelatorio)); - this.lsDadosRelatorio = lsDadosRelatorio; } @Override protected void processaParametros() throws Exception { + String fecInicio = parametros.get("fecInicio").toString() + " 00:00:00"; + String fecFinal = parametros.get("fecFinal").toString() + " 23:59:59"; + String empresa = parametros.get("empresa") != null ? parametros.get("empresa").toString() : ""; + String empresaNome = parametros.get("empresaNome") != null ? parametros.get("empresaNome").toString() : ""; + String puntoVenta = parametros.get("NUMPUNTOVENTA") != null ? parametros.get("NUMPUNTOVENTA").toString() : null; + parametros.put("tipoRelatorio", tipoRelatorio.name()); + lsDadosRelatorio = new ArrayList(); + + carregarDadosTotaisVenda(fecInicio, fecFinal, empresa, empresaNome, puntoVenta); + setLsDadosRelatorio(lsDadosRelatorio); } - private String carregarDadosTotaisdeVenda(String puntoVenta, String empresa) { + public abstract StringBuilder carregarDados(String puntoVenta, String empresa); - StringBuilder sql = new StringBuilder(); - sql.append(" SELECT pv.PUNTOVENTA_ID AS codigo, "); - sql.append(" pv.nombpuntoventa AS descricao, "); - sql.append(" COALESCE(SUM( "); - sql.append(" CASE "); - sql.append(" WHEN c.MOTIVOCANCELACION_ID IS NULL "); - sql.append(" AND (c.INDREMOTOINVERSO IS NULL "); - sql.append(" OR c.INDREMOTOINVERSO =0) "); - sql.append(" AND (c.INDSTATUSBOLETO <> 'E' AND c.TIPOVENTA_ID not in (5,12,18)) "); - sql.append(" THEN ( COALESCE(c.IMPORTEOUTROS,0) + COALESCE(c.IMPORTEPEDAGIO,0) +COALESCE(IMPORTETAXAEMBARQUE ,0)+COALESCE(c.preciopagado,0)) "); - sql.append(" ELSE null "); - sql.append(" END),0) AS valorBilhete, "); - sql.append(" COALESCE(COUNT( "); - sql.append(" CASE "); - sql.append(" WHEN c.MOTIVOCANCELACION_ID IS NULL "); - sql.append(" AND (c.INDREMOTOINVERSO IS NULL "); - sql.append(" OR c.INDREMOTOINVERSO =0) "); - sql.append(" AND (c.INDSTATUSBOLETO <> 'E' AND c.TIPOVENTA_ID not in (5,12,18)) "); - sql.append(" THEN c.caja_id "); - sql.append(" ELSE NULL "); - sql.append(" END),0) AS qtdBilhete, "); - sql.append(" SUM( "); - sql.append(" CASE "); - sql.append(" WHEN c.MOTIVOCANCELACION_ID IS NULL "); - sql.append(" AND COALESCE(c.IMPORTESEGURO,0) > 0 "); - sql.append(" THEN c.IMPORTESEGURO "); - sql.append(" ELSE 0 "); - sql.append(" END) AS valorSeguro, "); - sql.append(" COALESCE(COUNT( "); - sql.append(" CASE "); - sql.append(" WHEN c.MOTIVOCANCELACION_ID IS NULL "); - sql.append(" AND COALESCE(c.IMPORTESEGURO,0) > 0 "); - sql.append(" THEN 1 "); - sql.append(" ELSE NULL "); - sql.append(" END),0) AS qtdSeguro, "); - sql.append(" COALESCE(SUM( "); - sql.append(" CASE "); - sql.append(" WHEN c.MOTIVOCANCELACION_ID IS NULL "); - sql.append(" AND (c.INDSTATUSBOLETO = 'E' OR c.TIPOVENTA_ID in (5,18)) "); - sql.append(" THEN ( COALESCE(c.IMPORTEOUTROS,0) + COALESCE(c.IMPORTEPEDAGIO,0) +COALESCE(IMPORTETAXAEMBARQUE ,0)+COALESCE(c.preciopagado,0)) "); - sql.append(" ELSE 0 "); - sql.append(" END),0) AS valorVch, "); - sql.append(" COALESCE(COUNT( "); - sql.append(" CASE "); - sql.append(" WHEN c.MOTIVOCANCELACION_ID IS NULL "); - sql.append(" AND (c.INDSTATUSBOLETO = 'E' OR c.TIPOVENTA_ID in (5,18)) "); - sql.append(" THEN 1 "); - sql.append(" ELSE NULL "); - sql.append(" END),0) AS qtdVch, "); - sql.append(" COALESCE(SUM( "); - sql.append(" CASE "); - sql.append(" WHEN c.MOTIVOCANCELACION_ID IS NULL "); - sql.append(" AND c.TIPOVENTA_ID = 12 "); - sql.append(" THEN ( COALESCE(c.IMPORTEOUTROS,0) + COALESCE(c.IMPORTEPEDAGIO,0) +COALESCE(IMPORTETAXAEMBARQUE ,0)+COALESCE(c.preciopagado,0)) "); - sql.append(" ELSE 0 "); - sql.append(" END),0) AS valorInternet, "); - sql.append(" COALESCE(COUNT( "); - sql.append(" CASE "); - sql.append(" WHEN c.MOTIVOCANCELACION_ID IS NULL "); - sql.append(" AND c.TIPOVENTA_ID = 12 "); - sql.append(" THEN 1 "); - sql.append(" ELSE NULL "); - sql.append(" END),0) AS qtdInternet, "); - sql.append(" COALESCE(SUM( "); - sql.append(" CASE "); - sql.append(" WHEN c.MOTIVOCANCELACION_ID = 31 "); - sql.append(" THEN ( COALESCE(c.IMPORTEOUTROS,0) + COALESCE(c.IMPORTEPEDAGIO,0) +COALESCE(IMPORTETAXAEMBARQUE ,0)+COALESCE(c.preciopagado,0)) "); - sql.append(" ELSE 0 "); - sql.append(" END),0) AS valorCancelado, "); - sql.append(" COALESCE(COUNT( "); - sql.append(" CASE "); - sql.append(" WHEN c.MOTIVOCANCELACION_ID = 31 "); - sql.append(" THEN 1 "); - sql.append(" ELSE NULL "); - sql.append(" END),0) AS qtdCancelado, "); - sql.append(" COALESCE(SUM( "); - sql.append(" CASE "); - sql.append(" WHEN c.MOTIVOCANCELACION_ID IS NOT NULL "); - sql.append(" AND c.MOTIVOCANCELACION_ID <> 31 "); - sql.append(" THEN ( COALESCE(c.IMPORTEOUTROS,0) + COALESCE(c.IMPORTEPEDAGIO,0) +COALESCE(IMPORTETAXAEMBARQUE ,0)+COALESCE(c.preciopagado,0)) "); - sql.append(" ELSE 0 "); - sql.append(" END),0) AS valorEstornado, "); - sql.append(" COALESCE(COUNT( "); - sql.append(" CASE "); - sql.append(" WHEN c.MOTIVOCANCELACION_ID IS NOT NULL "); - sql.append(" AND c.MOTIVOCANCELACION_ID <> 31 "); - sql.append(" THEN 1 "); - sql.append(" ELSE NULL "); - sql.append(" END),0) AS qtdEstornado "); - sql.append(" "); + protected String criarQueryBilhetesVenda(String puntoVenta, String empresa) { + StringBuilder sql = this.carregarDados(puntoVenta, empresa); + return filtrosPadraoQueryRelatorioFechamento(puntoVenta, empresa, sql); + + } + + protected abstract String criarQueryReceitaDespesa(String puntoVenta, String empresa); + + /** + * @param puntoVenta + * @param empresa + * @param sql + */ + protected String filtrosPadraoQueryRelatorioFechamento(String puntoVenta, String empresa, StringBuilder sql) { sql.append(" FROM CAJA c "); sql.append(" INNER JOIN PUNTO_VENTA pv "); sql.append(" ON c.PUNTOVENTA_ID = pv.PUNTOVENTA_ID "); + sql.append(" LEFT JOIN PUNTO_VENTA PV_GERENCIA ON PV_GERENCIA.PUNTOVENTA_ID = PV.PUNTOVENTAPADRE_ID "); sql.append(" INNER JOIN marca m "); sql.append(" ON m.marca_id = c.marca_id "); sql.append(" WHERE c.TURNO_ID IS NOT NULL "); @@ -237,46 +71,149 @@ public class RelatorioAgenciaFechamento extends Relatorio { } sql.append(" AND c.TIPOVENTA_ID <> 6 "); sql.append(" AND c.INDREIMPRESION = 0 "); - if (empresa != null && !empresa.equals("") && !empresa.equals("-1")) { - sql.append(" AND m.empresa_id = "+empresa+" "); + if (empresa != null && !empresa.equals("") && !empresa.equals("-1")) { + sql.append(" AND m.empresa_id = " + empresa + " "); } - sql.append(" GROUP BY pv.PUNTOVENTA_ID, pv.nombpuntoventa "); - sql.append(" ORDER BY pv.nombpuntoventa "); + criarGroupByEOrderBy(sql); return sql.toString(); + } + + /** + * @param sql + */ + protected abstract void criarGroupByEOrderBy(StringBuilder sql); + + /** + * @param fecInicio + * @param fecFinal + * @param empresa + * @param empresaNome + * @param puntoVenta + * @throws SQLException + * @throws ParseException + */ + protected void carregarDadosTotaisVenda(String fecInicio, String fecFinal, String empresa, String empresaNome, String puntoVenta) throws SQLException, ParseException { + + NamedParameterStatement stmt = new NamedParameterStatement(getConexao(), criarQueryBilhetesVenda(puntoVenta, empresa)); + SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss"); + + stmt.setTimestamp("de", new java.sql.Timestamp(sdf.parse(fecInicio).getTime())); + stmt.setTimestamp("ate", new java.sql.Timestamp(sdf.parse(fecFinal).getTime())); + + ResultSet rset1 = stmt.executeQuery(); + + while (rset1.next()) { + + RelatorioAgenciaFechamentoAntigoBean agenciaFechamento = new RelatorioAgenciaFechamentoAntigoBean(); + BigDecimal total = BigDecimal.ZERO; + BigDecimal vendido = BigDecimal.ZERO; + + String puntoVentaId = rset1.getString("puntoventaId"); + + Integer qtdevendido = rset1.getInt("qtdevendido"); + Integer qtdedigitado = rset1.getInt("qtdedigitado"); + Integer qtdeAnulado = rset1.getInt("qtdeAnulado"); + Integer qtdeDevolvido = rset1.getInt("qtdeDevolvido"); + Integer qtdeTotal = null; + + vendido = rset1.getBigDecimal("vendido"); + BigDecimal digitado = rset1.getBigDecimal("digitado"); + BigDecimal anulado = rset1.getBigDecimal("anulado"); + BigDecimal devolvido = rset1.getBigDecimal("devolvido"); + + agenciaFechamento.setEmpresa(empresaNome); + + agenciaFechamento.setCodigo(rset1.getString("codigo")); + agenciaFechamento.setDescricao(rset1.getString("descricao")); + if (TipoRelatorioFechamentoEnum.DIARIO.equals(tipoRelatorio)) { + agenciaFechamento.setData(rset1.getDate("data")); + } + if (!TipoRelatorioFechamentoEnum.ANTIGO.equals(tipoRelatorio)) { + agenciaFechamento.setSubordinado(rset1.getString("subordinado")); + } + agenciaFechamento.setQtdeVendido(qtdevendido != null ? qtdevendido : NumberUtils.INTEGER_ZERO); + agenciaFechamento.setQtdeDigitado(qtdedigitado != null ? qtdedigitado : NumberUtils.INTEGER_ZERO); + agenciaFechamento.setQtdeAnulado(qtdeAnulado != null ? qtdeAnulado : NumberUtils.INTEGER_ZERO); + agenciaFechamento.setQtdeDevolvido(qtdeDevolvido != null ? qtdeDevolvido : NumberUtils.INTEGER_ZERO); + + qtdeTotal = ((qtdevendido != null ? qtdevendido : NumberUtils.INTEGER_ZERO) + (qtdedigitado != null ? qtdedigitado : NumberUtils.INTEGER_ZERO)) + - ((qtdeAnulado != null ? qtdeAnulado : NumberUtils.INTEGER_ZERO) + (qtdeDevolvido != null ? qtdeDevolvido : NumberUtils.INTEGER_ZERO)); + + if (qtdeTotal < 0) { + qtdeTotal = NumberUtils.INTEGER_ZERO; + } + + agenciaFechamento.setQtdeTotal(qtdeTotal); + + agenciaFechamento.setDigitado(digitado != null ? digitado : BigDecimal.ZERO); + agenciaFechamento.setAnulado(anulado != null ? anulado : BigDecimal.ZERO); + agenciaFechamento.setDevolvido(devolvido != null ? devolvido : BigDecimal.ZERO); + + total = total.add(vendido != null ? vendido : BigDecimal.ZERO); + total = total.add(digitado != null ? digitado : BigDecimal.ZERO); + total = total.subtract(anulado != null ? anulado : BigDecimal.ZERO); + total = total.subtract(devolvido != null ? devolvido : BigDecimal.ZERO); + + carregarDadosReceitaDespesa(fecInicio, fecFinal, empresa, sdf, agenciaFechamento, total, vendido, puntoVentaId); + lsDadosRelatorio.add(agenciaFechamento); + } } - - private String carregarEventosExtras(String puntoVenta, String empresa) { - StringBuilder sql = new StringBuilder(); - sql.append(" SELECT "); - sql.append(" COALESCE(SUM(CASE WHEN tee.CVETIPOEVENTO = 'EXCESSO_BAGAGEM' THEN cd.PRECIO ELSE NULL END),0) AS valorExcesso, "); - sql.append(" COALESCE(COUNT(CASE WHEN tee.CVETIPOEVENTO = 'EXCESSO_BAGAGEM' THEN 1 ELSE NULL END),0) as qtdExcesso, "); - sql.append(" COALESCE(SUM(CASE WHEN tee.CVETIPOEVENTO = 'SEGURO_OPCIONAL' THEN cd.PRECIO ELSE NULL END),0) AS valorSeguro, "); - sql.append(" COALESCE(COUNT(CASE WHEN tee.CVETIPOEVENTO = 'SEGURO_OPCIONAL' THEN 1 ELSE NULL END),0) as qtdSeguro "); - sql.append(" FROM CAJA_DIVERSOS cd "); - sql.append(" INNER JOIN EVENTO_EXTRA ee "); - sql.append(" ON ee.EVENTOEXTRA_ID = cd.EVENTOEXTRA_ID "); - sql.append(" INNER JOIN TIPO_EVENTO_EXTRA tee "); - sql.append(" ON ee.TIPOEVENTOEXTRA_ID = tee.TIPOEVENTOEXTRA_ID "); - sql.append(" WHERE cd.MOTIVOCANCELACION_ID IS NULL "); - sql.append(" AND ee.activo = 1 "); - sql.append(" AND cd.TURNO_ID IS NOT NULL "); - sql.append(" AND tee.CVETIPOEVENTO in ('EXCESSO_BAGAGEM', 'SEGURO_OPCIONAL' ) "); - sql.append(" AND cd.FECCORTE BETWEEN :de AND :ate "); - if (puntoVenta != null && !puntoVenta.equals("-1")) { - sql.append(" AND cd.PUNTOVENTA_ID = ").append(puntoVenta); + public void setLsDadosRelatorio(List lsDadosRelatorio) { + this.setCollectionDataSource(new JRBeanCollectionDataSource(lsDadosRelatorio)); + this.lsDadosRelatorio = lsDadosRelatorio; + } + + /** + * @param fecInicio + * @param fecFinal + * @param empresa + * @param sdf + * @param agenciaFechamento + * @param total + * @param vendido + * @param puntoVentaId + * @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 { + NamedParameterStatement stmt = new NamedParameterStatement(getConexao(), criarQueryReceitaDespesa(puntoVentaId, empresa)); + + stmt.setTimestamp("de", new java.sql.Timestamp(sdf.parse(fecInicio).getTime())); + stmt.setTimestamp("ate", new java.sql.Timestamp(sdf.parse(fecFinal).getTime())); + + ResultSet rset2 = stmt.executeQuery(); + + if (rset2.next()) { + + Integer qtdedespesa = rset2.getInt("qtdedespesa"); + BigDecimal receita = rset2.getBigDecimal("receita"); + BigDecimal despesa = rset2.getBigDecimal("despesa"); + + agenciaFechamento.setQtdeDespesa(qtdedespesa != null ? qtdedespesa : NumberUtils.INTEGER_ZERO); + agenciaFechamento.setReceita(receita != null ? receita : BigDecimal.ZERO); + agenciaFechamento.setDespesa(despesa != null ? despesa : BigDecimal.ZERO); + + total = total.add(receita != null ? receita : BigDecimal.ZERO); + total = total.subtract(despesa != null ? despesa : BigDecimal.ZERO); + + agenciaFechamento.setVendido(vendido != null ? vendido : BigDecimal.ZERO); + agenciaFechamento.setTotal(total); + + } else { + agenciaFechamento.setQtdeDespesa(NumberUtils.INTEGER_ZERO); + agenciaFechamento.setReceita(BigDecimal.ZERO); + agenciaFechamento.setDespesa(BigDecimal.ZERO); + agenciaFechamento.setVendido(vendido != null ? vendido : BigDecimal.ZERO); + agenciaFechamento.setTotal(total); } - if (empresa != null && !empresa.equals("") && !empresa.equals("-1")) { - sql.append(" AND ee.EMPRESA_ID = "+empresa+" "); - } - - - log.debug(sql.toString()); - - return sql.toString(); + // Estava dando um erro de "máximo de cursores abertos excedido" + // Colocado isso o erro parou de ocorrer + rset2.getStatement().close(); + rset2.close(); } } diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioAgenciaFechamentoAntigo.java b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioAgenciaFechamentoAntigo.java index 2ef5c2498..f61dfdba3 100644 --- a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioAgenciaFechamentoAntigo.java +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioAgenciaFechamentoAntigo.java @@ -1,165 +1,17 @@ package com.rjconsultores.ventaboletos.relatorios.impl; -import java.math.BigDecimal; import java.sql.Connection; -import java.sql.ResultSet; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.List; import java.util.Map; -import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource; - -import org.apache.commons.lang.math.NumberUtils; - -import com.rjconsultores.ventaboletos.relatorios.utilitarios.DataSource; -import com.rjconsultores.ventaboletos.relatorios.utilitarios.Relatorio; -import com.rjconsultores.ventaboletos.relatorios.utilitarios.RelatorioAgenciaFechamentoAntigoBean; -import com.rjconsultores.ventaboletos.relatorios.utilitarios.RelatorioAgenciaFechamentoBean; -import com.rjconsultores.ventaboletos.web.utilerias.NamedParameterStatement; - -public class RelatorioAgenciaFechamentoAntigo extends Relatorio { - - private List lsDadosRelatorio; +public class RelatorioAgenciaFechamentoAntigo extends RelatorioAgenciaFechamento { public RelatorioAgenciaFechamentoAntigo(Map parametros, Connection conexao) throws Exception { super(parametros, conexao); - - this.setCustomDataSource(new DataSource(this) { - @Override - public void initDados() throws Exception { - - Connection conexao = this.relatorio.getConexao(); - - Map parametros = this.relatorio.getParametros(); - - String fecInicio = parametros.get("fecInicio").toString() + " 00:00:00"; - String fecFinal = parametros.get("fecFinal").toString() + " 23:59:59"; - String empresa = parametros.get("empresa") != null ? parametros.get("empresa").toString() : ""; - String empresaNome = parametros.get("empresaNome") != null ? parametros.get("empresaNome").toString() : ""; - String puntoVenta = parametros.get("NUMPUNTOVENTA") != null ? parametros.get("NUMPUNTOVENTA").toString() : null; - - lsDadosRelatorio = new ArrayList(); - - String sql = carregarDadosTotaisdeVenda(puntoVenta, empresa); - - System.out.println(sql); - - NamedParameterStatement stmt = new NamedParameterStatement(conexao, sql); - ResultSet rset1 = null; - ResultSet rset2 = null; - SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss"); - - stmt.setTimestamp("de", new java.sql.Timestamp(sdf.parse(fecInicio).getTime())); - stmt.setTimestamp("ate", new java.sql.Timestamp(sdf.parse(fecFinal).getTime())); - - rset1= stmt.executeQuery(); - - while (rset1.next()) { - - RelatorioAgenciaFechamentoAntigoBean agenciaFechamento = new RelatorioAgenciaFechamentoAntigoBean(); - BigDecimal total = BigDecimal.ZERO; - BigDecimal vendido = BigDecimal.ZERO; - - String puntoVentaId = rset1.getString("codigo"); - - Integer qtdevendido = rset1.getInt("qtdevendido"); - Integer qtdedigitado = rset1.getInt("qtdedigitado"); - Integer qtdeAnulado = rset1.getInt("qtdeAnulado"); - Integer qtdeDevolvido = rset1.getInt("qtdeDevolvido"); - Integer qtdeTotal = null; - - vendido = rset1.getBigDecimal("vendido"); - BigDecimal digitado = rset1.getBigDecimal("digitado"); - BigDecimal anulado = rset1.getBigDecimal("anulado"); - BigDecimal devolvido = rset1.getBigDecimal("devolvido"); - - agenciaFechamento.setEmpresa(empresaNome); - - agenciaFechamento.setCodigo(rset1.getString("codigo")); - agenciaFechamento.setDescricao(rset1.getString("descricao")); - - agenciaFechamento.setQtdeVendido(qtdevendido != null ? qtdevendido : NumberUtils.INTEGER_ZERO); - agenciaFechamento.setQtdeDigitado(qtdedigitado != null ? qtdedigitado : NumberUtils.INTEGER_ZERO); - agenciaFechamento.setQtdeAnulado(qtdeAnulado != null ? qtdeAnulado : NumberUtils.INTEGER_ZERO); - agenciaFechamento.setQtdeDevolvido(qtdeDevolvido != null ? qtdeDevolvido : NumberUtils.INTEGER_ZERO); - - qtdeTotal = ((qtdevendido != null ? qtdevendido : NumberUtils.INTEGER_ZERO) + (qtdedigitado != null ? qtdedigitado : NumberUtils.INTEGER_ZERO)) - - ((qtdeAnulado != null ? qtdeAnulado : NumberUtils.INTEGER_ZERO) + (qtdeDevolvido != null ? qtdeDevolvido : NumberUtils.INTEGER_ZERO)); - - if (qtdeTotal < 0) { - qtdeTotal = NumberUtils.INTEGER_ZERO; - } - - agenciaFechamento.setQtdeTotal(qtdeTotal); - - agenciaFechamento.setDigitado(digitado != null ? digitado : BigDecimal.ZERO); - agenciaFechamento.setAnulado(anulado != null ? anulado : BigDecimal.ZERO); - agenciaFechamento.setDevolvido(devolvido != null ? devolvido : BigDecimal.ZERO); - - total = total.add(vendido != null ? vendido : BigDecimal.ZERO); - total = total.add(digitado != null ? digitado : BigDecimal.ZERO); - total = total.subtract(anulado != null ? anulado : BigDecimal.ZERO); - total = total.subtract(devolvido != null ? devolvido : BigDecimal.ZERO); - String strQueryReceitaDespesas = carregarDadosReceitaDespesa(puntoVentaId, empresa); - stmt = new NamedParameterStatement(conexao, strQueryReceitaDespesas); - - stmt.setTimestamp("de", new java.sql.Timestamp(sdf.parse(fecInicio).getTime())); - stmt.setTimestamp("ate", new java.sql.Timestamp(sdf.parse(fecFinal).getTime())); - - rset2 = stmt.executeQuery(); - - if (rset2.next()) { - - Integer qtdedespesa = rset2.getInt("qtdedespesa"); - BigDecimal receita = rset2.getBigDecimal("receita"); - BigDecimal despesa = rset2.getBigDecimal("despesa"); - - agenciaFechamento.setQtdeDespesa(qtdedespesa != null ? qtdedespesa : NumberUtils.INTEGER_ZERO); - agenciaFechamento.setReceita(receita != null ? receita : BigDecimal.ZERO); - agenciaFechamento.setDespesa(despesa != null ? despesa : BigDecimal.ZERO); - - total = total.add(receita != null ? receita : BigDecimal.ZERO); - total = total.subtract(despesa != null ? despesa : BigDecimal.ZERO); - - agenciaFechamento.setVendido(vendido != null ? vendido : BigDecimal.ZERO); - agenciaFechamento.setTotal(total); - - } else { - agenciaFechamento.setQtdeDespesa(NumberUtils.INTEGER_ZERO); - agenciaFechamento.setReceita(BigDecimal.ZERO); - agenciaFechamento.setDespesa(BigDecimal.ZERO); - agenciaFechamento.setVendido(vendido != null ? vendido : BigDecimal.ZERO); - agenciaFechamento.setTotal(total); - } - - lsDadosRelatorio.add(agenciaFechamento); - //Estava dando um erro de "máximo de cursores abertos excedido" - //Colocado isso o erro parou de ocorrer - rset2.getStatement().close(); - rset2.close(); - } - - if (lsDadosRelatorio.size() > 0) { - - setLsDadosRelatorio(lsDadosRelatorio); - } - - } - }); - } - - public void setLsDadosRelatorio(List lsDadosRelatorio) { - this.setCollectionDataSource(new JRBeanCollectionDataSource(lsDadosRelatorio)); - this.lsDadosRelatorio = lsDadosRelatorio; + tipoRelatorio = TipoRelatorioFechamentoEnum.ANTIGO; } @Override - protected void processaParametros() throws Exception { - } - - private String carregarDadosTotaisdeVenda(String puntoVenta, String empresa) { - + public StringBuilder carregarDados(String puntoVenta, String empresa) { StringBuilder sql = new StringBuilder(); sql.append(" SELECT "); sql.append(" pv.PUNTOVENTA_ID AS codigo, "); @@ -186,43 +38,13 @@ public class RelatorioAgenciaFechamentoAntigo extends Relatorio { sql.append(" "); sql.append(" COALESCE(SUM(CASE WHEN c.MOTIVOCANCELACION_ID is not null and c.MOTIVOCANCELACION_ID = 32 THEN ( "); sql.append(" coalesce(c.IMPORTEOUTROS,0) + coalesce(c.IMPORTEPEDAGIO,0) + coalesce(c.IMPORTESEGURO,0) "); - sql.append(" +coalesce(IMPORTETAXAEMBARQUE ,0)+coalesce(c.preciopagado,0)) ELSE NULL END),0) AS devolvido "); - sql.append(" "); - sql.append(" "); - sql.append(" FROM CAJA c "); - sql.append(" INNER JOIN PUNTO_VENTA pv ON c.PUNTOVENTA_ID = pv.PUNTOVENTA_ID "); - sql.append(" inner join marca m on m.marca_id = c.marca_id "); - sql.append(" WHERE c.TURNO_ID IS NOT NULL "); - sql.append(" AND c.FECCORTE BETWEEN :de AND :ate "); - if (puntoVenta != null && !puntoVenta.equals("-1")) { - sql.append(" AND c.PUNTOVENTA_ID in (" + puntoVenta + ") "); - } - sql.append(" AND c.TIPOVENTA_ID <> 6 "); - sql.append(" AND c.INDREIMPRESION = 0 "); - if (empresa != null && !empresa.equals("") && !empresa.equals("-1")) { - sql.append(" AND m.empresa_id = "+empresa+" "); - } - sql.append(" GROUP BY pv.PUNTOVENTA_ID , pv.nombpuntoventa "); - sql.append(" ORDER BY pv.PUNTOVENTA_ID , pv.nombpuntoventa "); - - return sql.toString(); - + sql.append(" +coalesce(IMPORTETAXAEMBARQUE ,0)+coalesce(c.preciopagado,0)) ELSE NULL END),0) AS devolvido, "); + sql.append(" pv.PUNTOVENTA_ID AS puntoventaId "); + return sql; } - private String carregaAgenciasComVenda() { - - StringBuilder sql = new StringBuilder(); - sql.append(" SELECT DISTINCT cc.PUNTOVENTA_ID "); - sql.append(" FROM CONTA_CORRENTE_PTOVTA cc "); - sql.append(" WHERE cc.FECHOROPERACION BETWEEN :de AND :ate "); - sql.append(" and cc.EMPRESA_ID = :empresaId "); - - return sql.toString(); - - } - - private String carregarDadosReceitaDespesa(String puntoVenta, String empresa) { - + @Override + protected String criarQueryReceitaDespesa(String puntoVenta, String empresa) { StringBuilder sql = new StringBuilder(); sql.append(" SELECT "); sql.append(" COALESCE(COUNT(CASE WHEN cdp.IMPORTE < 0 THEN 1 ELSE NULL END),0) as qtdedespesa, "); @@ -238,26 +60,20 @@ public class RelatorioAgenciaFechamentoAntigo extends Relatorio { sql.append(" AND cd.TURNO_ID IS NOT NULL "); sql.append(" AND cd.FECCORTE BETWEEN :de AND :ate "); if (puntoVenta != null && !puntoVenta.equals("-1")) { - sql.append(" AND cd.PUNTOVENTA_ID = "+puntoVenta+" "); + sql.append(" AND cd.PUNTOVENTA_ID = " + puntoVenta + " "); } - if (empresa != null && !empresa.equals("") && !empresa.equals("-1")) { - sql.append(" AND ee.EMPRESA_ID = "+empresa+" "); + if (empresa != null && !empresa.equals("") && !empresa.equals("-1")) { + sql.append(" AND ee.EMPRESA_ID = " + empresa + " "); } - return sql.toString(); + } + + @Override + protected void criarGroupByEOrderBy(StringBuilder sql) { + sql.append(" GROUP BY pv.PUNTOVENTA_ID , pv.nombpuntoventa "); + sql.append(" ORDER BY pv.PUNTOVENTA_ID , pv.nombpuntoventa "); } - private String carregarNomeEmpresa() { - - StringBuilder sql = new StringBuilder(); - sql.append(" SELECT "); - sql.append(" NOMBEMPRESA "); - sql.append(" FROM EMPRESA "); - sql.append(" WHERE EMPRESA_ID=:empresaId "); - - return sql.toString(); - - } } diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioAgenciaFechamentoDiario.java b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioAgenciaFechamentoDiario.java new file mode 100644 index 000000000..0a43ecbf4 --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioAgenciaFechamentoDiario.java @@ -0,0 +1,75 @@ +package com.rjconsultores.ventaboletos.relatorios.impl; + +import java.sql.Connection; +import java.util.Map; + +public class RelatorioAgenciaFechamentoDiario extends RelatorioAgenciaFechamento { + + public RelatorioAgenciaFechamentoDiario(Map parametros, Connection conexao) throws Exception { + super(parametros, conexao); + tipoRelatorio = TipoRelatorioFechamentoEnum.DIARIO; + } + + @Override + protected String criarQueryReceitaDespesa(String puntoVenta, String empresa) { + + StringBuilder sql = new StringBuilder(); + sql.append(" SELECT "); + sql.append(" COALESCE(COUNT(CASE WHEN cdp.IMPORTE < 0 THEN 1 ELSE NULL END),0) as qtdedespesa, "); + sql.append(" COALESCE(SUM(CASE WHEN cdp.IMPORTE > 0 THEN cdp.IMPORTE ELSE NULL END),0) AS receita, "); + sql.append(" COALESCE(ABS(SUM(CASE WHEN cdp.IMPORTE < 0 THEN cdp.IMPORTE ELSE NULL END)),0) AS despesa "); + sql.append(" FROM CAJA_DIVERSOS cd, "); + sql.append(" CAJA_DIVERSOS_PAGO cdp, "); + sql.append(" EVENTO_EXTRA ee "); + sql.append(" WHERE cd.MOTIVOCANCELACION_ID IS NULL "); + sql.append(" AND ee.EVENTOEXTRA_ID = cd.EVENTOEXTRA_ID "); + sql.append(" AND cdp.CAJADIVERSOS_ID = cd.CAJADIVERSOS_ID "); + sql.append(" AND ee.activo = 1 "); + sql.append(" AND cd.TURNO_ID IS NOT NULL "); + sql.append(" AND cd.FECCORTE BETWEEN :de AND :ate "); + if (puntoVenta != null && !puntoVenta.equals("-1")) { + sql.append(" AND cd.PUNTOVENTA_ID = " + puntoVenta + " "); + } + if (empresa != null && !empresa.equals("") && !empresa.equals("-1")) { + sql.append(" AND ee.EMPRESA_ID = " + empresa + " "); + } + + return sql.toString(); + + } + + @Override + public StringBuilder carregarDados(String puntoVenta, String empresa) { + StringBuilder sql = new StringBuilder(); + sql.append(" SELECT "); + sql.append(" pv.NUMPUNTOVENTA AS codigo, "); + sql.append(" pv.nombpuntoventa AS descricao, "); + sql.append(" c.feccorte AS data, "); + sql.append(" PV_GERENCIA.NUMPUNTOVENTA AS subordinado, "); + sql.append(" COALESCE(COUNT(CASE WHEN c.MOTIVOCANCELACION_ID IS NULL and (c.INDREMOTOINVERSO is null or c.INDREMOTOINVERSO =0) THEN c.caja_id ELSE NULL END),0) AS qtdevendido, "); + sql.append(" COALESCE(COUNT(CASE WHEN c.INDREMOTOINVERSO = 1 THEN 1 ELSE NULL END),0) AS qtdedigitado, "); + sql.append(" COALESCE(COUNT(CASE WHEN c.MOTIVOCANCELACION_ID = 31 THEN 1 ELSE NULL END),0) AS qtdeAnulado, "); + sql.append(" COALESCE(COUNT(CASE WHEN c.MOTIVOCANCELACION_ID is not null and c.MOTIVOCANCELACION_ID = 32 THEN 1 ELSE NULL END),0) AS qtdeDevolvido, "); + sql.append(" COALESCE(SUM(CASE WHEN c.MOTIVOCANCELACION_ID IS NULL and (c.INDREMOTOINVERSO is null or c.INDREMOTOINVERSO =0) THEN ( "); + sql.append(" coalesce(c.IMPORTEOUTROS,0) + coalesce(c.IMPORTEPEDAGIO,0) + coalesce(c.IMPORTESEGURO,0) "); + sql.append(" +coalesce(IMPORTETAXAEMBARQUE ,0)+coalesce(c.preciopagado,0)) ELSE NULL END),0) AS vendido, "); + sql.append(" COALESCE(SUM(CASE WHEN c.MOTIVOCANCELACION_ID IS NULL and c.INDREMOTOINVERSO = 1 THEN ( "); + sql.append(" coalesce(c.IMPORTEOUTROS,0) + coalesce(c.IMPORTEPEDAGIO,0) + coalesce(c.IMPORTESEGURO,0) "); + sql.append(" +coalesce(IMPORTETAXAEMBARQUE ,0)+coalesce(c.preciopagado,0)) ELSE NULL END),0) AS digitado, "); + sql.append(" COALESCE(SUM(CASE WHEN c.MOTIVOCANCELACION_ID = 31 THEN ( "); + sql.append(" coalesce(c.IMPORTEOUTROS,0) + coalesce(c.IMPORTEPEDAGIO,0) + coalesce(c.IMPORTESEGURO,0) "); + sql.append(" +coalesce(IMPORTETAXAEMBARQUE ,0)+coalesce(c.preciopagado,0)) ELSE NULL END),0) AS anulado, "); + sql.append(" COALESCE(SUM(CASE WHEN c.MOTIVOCANCELACION_ID is not null and c.MOTIVOCANCELACION_ID = 32 THEN ( "); + sql.append(" coalesce(c.IMPORTEOUTROS,0) + coalesce(c.IMPORTEPEDAGIO,0) + coalesce(c.IMPORTESEGURO,0) "); + sql.append(" +coalesce(IMPORTETAXAEMBARQUE ,0)+coalesce(c.preciopagado,0)) ELSE NULL END),0) AS devolvido, "); + sql.append(" pv.PUNTOVENTA_ID AS puntoventaId "); + return sql; + } + + @Override + protected void criarGroupByEOrderBy(StringBuilder sql) { + sql.append(" GROUP BY pv.NUMPUNTOVENTA , pv.nombpuntoventa, pv.puntoventa_id, c.feccorte, PV_GERENCIA.NUMPUNTOVENTA "); + sql.append(" ORDER BY pv.nombpuntoventa, c.feccorte "); + } + +} diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioAgenciaFechamentoNovo.java b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioAgenciaFechamentoNovo.java new file mode 100644 index 000000000..c616a9603 --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioAgenciaFechamentoNovo.java @@ -0,0 +1,283 @@ +package com.rjconsultores.ventaboletos.relatorios.impl; + +import java.math.BigDecimal; +import java.sql.Connection; +import java.sql.ResultSet; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import org.apache.commons.lang.math.NumberUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.rjconsultores.ventaboletos.relatorios.utilitarios.DataSource; +import com.rjconsultores.ventaboletos.relatorios.utilitarios.Relatorio; +import com.rjconsultores.ventaboletos.relatorios.utilitarios.RelatorioAgenciaFechamentoBean; +import com.rjconsultores.ventaboletos.web.utilerias.NamedParameterStatement; + +import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource; + +public class RelatorioAgenciaFechamentoNovo extends Relatorio { + + private static Logger log = LoggerFactory.getLogger(RelatorioAgenciaFechamentoNovo.class); + + private List lsDadosRelatorio; + + public RelatorioAgenciaFechamentoNovo(Map parametros, Connection conexao) throws Exception { + super(parametros, conexao); + + this.setCustomDataSource(new DataSource(this) { + @Override + public void initDados() throws Exception { + + Connection conexao = this.relatorio.getConexao(); + + Map parametros = this.relatorio.getParametros(); + + String fecInicio = parametros.get("fecInicio").toString() + " 00:00:00"; + String fecFinal = parametros.get("fecFinal").toString() + " 23:59:59"; + String empresa = parametros.get("empresa") != null ? parametros.get("empresa").toString() : ""; + String empresaNome = parametros.get("empresaNome") != null ? parametros.get("empresaNome").toString() : ""; + String puntoVenta = parametros.get("NUMPUNTOVENTA") != null ? parametros.get("NUMPUNTOVENTA").toString() : null; + + lsDadosRelatorio = new ArrayList(); + + String sql = carregarDadosTotaisdeVenda(puntoVenta, empresa); + + log.debug(sql); + + NamedParameterStatement stmt = new NamedParameterStatement(conexao, sql); + ResultSet rset1 = null; + ResultSet rset2 = null; + SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss"); + + stmt.setTimestamp("de", new java.sql.Timestamp(sdf.parse(fecInicio).getTime())); + stmt.setTimestamp("ate", new java.sql.Timestamp(sdf.parse(fecFinal).getTime())); + + rset1= stmt.executeQuery(); + + while (rset1.next()) { + + Integer qtdExcesso = NumberUtils.INTEGER_ZERO; + Integer qtdSeguro = NumberUtils.INTEGER_ZERO; + + BigDecimal valorExcesso = BigDecimal.ZERO; + BigDecimal valorSeguro = BigDecimal.ZERO; + + RelatorioAgenciaFechamentoBean agenciaFechamento = new RelatorioAgenciaFechamentoBean(); + + agenciaFechamento.setEmpresa(empresaNome); + String puntoVentaId = rset1.getString("codigo"); + agenciaFechamento.setDescricao(rset1.getString("descricao")); + + agenciaFechamento.setValorBilhete(rset1.getBigDecimal("valorBilhete")); + agenciaFechamento.setValorVch(rset1.getBigDecimal("valorVch")); + agenciaFechamento.setValorInternet(rset1.getBigDecimal("valorInternet")); + agenciaFechamento.setValorCancelado(rset1.getBigDecimal("valorCancelado")); + agenciaFechamento.setValorEstornado(rset1.getBigDecimal("valorEstornado")); + valorSeguro = rset1.getBigDecimal("valorSeguro"); + + agenciaFechamento.setQtdBilhete(rset1.getInt("qtdBilhete")); + agenciaFechamento.setQtdVch(rset1.getInt("qtdVch")); + agenciaFechamento.setQtdInternet(rset1.getInt("qtdInternet")); + agenciaFechamento.setQtdCancelado(rset1.getInt("qtdCancelado")); + agenciaFechamento.setQtdEstornado(rset1.getInt("qtdEstornado")); + qtdSeguro = rset1.getInt("qtdSeguro"); + + String strQueryEventoExtra = carregarEventosExtras(puntoVentaId, empresa); + stmt = new NamedParameterStatement(conexao, strQueryEventoExtra); + + stmt.setTimestamp("de", new java.sql.Timestamp(sdf.parse(fecInicio).getTime())); + stmt.setTimestamp("ate", new java.sql.Timestamp(sdf.parse(fecFinal).getTime())); + + rset2 = stmt.executeQuery(); + + if (rset2.next()) { + + qtdSeguro += rset2.getInt("qtdSeguro"); + qtdExcesso = rset2.getInt("qtdExcesso"); + + valorSeguro = valorSeguro.add(rset2.getBigDecimal("valorSeguro")); + valorExcesso = valorExcesso.add(rset2.getBigDecimal("valorExcesso")); + } + + agenciaFechamento.setQtdExcesso(qtdExcesso); + agenciaFechamento.setQtdSeguro(qtdSeguro); + agenciaFechamento.setValorExcesso(valorExcesso); + agenciaFechamento.setValorSeguro(valorSeguro); + + lsDadosRelatorio.add(agenciaFechamento); + //Estava dando um erro de "máximo de cursores abertos excedido" + //Colocado isso o erro parou de ocorrer + rset2.getStatement().close(); + rset2.close(); + } + + rset1.close(); + + if (!lsDadosRelatorio.isEmpty()) { + setLsDadosRelatorio(lsDadosRelatorio); + } + + } + }); + } + + public void setLsDadosRelatorio(List lsDadosRelatorio) { + this.setCollectionDataSource(new JRBeanCollectionDataSource(lsDadosRelatorio)); + this.lsDadosRelatorio = lsDadosRelatorio; + } + + @Override + protected void processaParametros() throws Exception { + } + + private String carregarDadosTotaisdeVenda(String puntoVenta, String empresa) { + + StringBuilder sql = new StringBuilder(); + sql.append(" SELECT pv.PUNTOVENTA_ID AS codigo, "); + sql.append(" pv.nombpuntoventa AS descricao, "); + sql.append(" COALESCE(SUM( "); + sql.append(" CASE "); + sql.append(" WHEN c.MOTIVOCANCELACION_ID IS NULL "); + sql.append(" AND (c.INDREMOTOINVERSO IS NULL "); + sql.append(" OR c.INDREMOTOINVERSO =0) "); + sql.append(" AND (c.INDSTATUSBOLETO <> 'E' AND c.TIPOVENTA_ID not in (5,12,18)) "); + sql.append(" THEN ( COALESCE(c.IMPORTEOUTROS,0) + COALESCE(c.IMPORTEPEDAGIO,0) +COALESCE(IMPORTETAXAEMBARQUE ,0)+COALESCE(c.preciopagado,0)) "); + sql.append(" ELSE null "); + sql.append(" END),0) AS valorBilhete, "); + sql.append(" COALESCE(COUNT( "); + sql.append(" CASE "); + sql.append(" WHEN c.MOTIVOCANCELACION_ID IS NULL "); + sql.append(" AND (c.INDREMOTOINVERSO IS NULL "); + sql.append(" OR c.INDREMOTOINVERSO =0) "); + sql.append(" AND (c.INDSTATUSBOLETO <> 'E' AND c.TIPOVENTA_ID not in (5,12,18)) "); + sql.append(" THEN c.caja_id "); + sql.append(" ELSE NULL "); + sql.append(" END),0) AS qtdBilhete, "); + sql.append(" SUM( "); + sql.append(" CASE "); + sql.append(" WHEN c.MOTIVOCANCELACION_ID IS NULL "); + sql.append(" AND COALESCE(c.IMPORTESEGURO,0) > 0 "); + sql.append(" THEN c.IMPORTESEGURO "); + sql.append(" ELSE 0 "); + sql.append(" END) AS valorSeguro, "); + sql.append(" COALESCE(COUNT( "); + sql.append(" CASE "); + sql.append(" WHEN c.MOTIVOCANCELACION_ID IS NULL "); + sql.append(" AND COALESCE(c.IMPORTESEGURO,0) > 0 "); + sql.append(" THEN 1 "); + sql.append(" ELSE NULL "); + sql.append(" END),0) AS qtdSeguro, "); + sql.append(" COALESCE(SUM( "); + sql.append(" CASE "); + sql.append(" WHEN c.MOTIVOCANCELACION_ID IS NULL "); + sql.append(" AND (c.INDSTATUSBOLETO = 'E' OR c.TIPOVENTA_ID in (5,18)) "); + sql.append(" THEN ( COALESCE(c.IMPORTEOUTROS,0) + COALESCE(c.IMPORTEPEDAGIO,0) +COALESCE(IMPORTETAXAEMBARQUE ,0)+COALESCE(c.preciopagado,0)) "); + sql.append(" ELSE 0 "); + sql.append(" END),0) AS valorVch, "); + sql.append(" COALESCE(COUNT( "); + sql.append(" CASE "); + sql.append(" WHEN c.MOTIVOCANCELACION_ID IS NULL "); + sql.append(" AND (c.INDSTATUSBOLETO = 'E' OR c.TIPOVENTA_ID in (5,18)) "); + sql.append(" THEN 1 "); + sql.append(" ELSE NULL "); + sql.append(" END),0) AS qtdVch, "); + sql.append(" COALESCE(SUM( "); + sql.append(" CASE "); + sql.append(" WHEN c.MOTIVOCANCELACION_ID IS NULL "); + sql.append(" AND c.TIPOVENTA_ID = 12 "); + sql.append(" THEN ( COALESCE(c.IMPORTEOUTROS,0) + COALESCE(c.IMPORTEPEDAGIO,0) +COALESCE(IMPORTETAXAEMBARQUE ,0)+COALESCE(c.preciopagado,0)) "); + sql.append(" ELSE 0 "); + sql.append(" END),0) AS valorInternet, "); + sql.append(" COALESCE(COUNT( "); + sql.append(" CASE "); + sql.append(" WHEN c.MOTIVOCANCELACION_ID IS NULL "); + sql.append(" AND c.TIPOVENTA_ID = 12 "); + sql.append(" THEN 1 "); + sql.append(" ELSE NULL "); + sql.append(" END),0) AS qtdInternet, "); + sql.append(" COALESCE(SUM( "); + sql.append(" CASE "); + sql.append(" WHEN c.MOTIVOCANCELACION_ID = 31 "); + sql.append(" THEN ( COALESCE(c.IMPORTEOUTROS,0) + COALESCE(c.IMPORTEPEDAGIO,0) +COALESCE(IMPORTETAXAEMBARQUE ,0)+COALESCE(c.preciopagado,0)) "); + sql.append(" ELSE 0 "); + sql.append(" END),0) AS valorCancelado, "); + sql.append(" COALESCE(COUNT( "); + sql.append(" CASE "); + sql.append(" WHEN c.MOTIVOCANCELACION_ID = 31 "); + sql.append(" THEN 1 "); + sql.append(" ELSE NULL "); + sql.append(" END),0) AS qtdCancelado, "); + sql.append(" COALESCE(SUM( "); + sql.append(" CASE "); + sql.append(" WHEN c.MOTIVOCANCELACION_ID IS NOT NULL "); + sql.append(" AND c.MOTIVOCANCELACION_ID <> 31 "); + sql.append(" THEN ( COALESCE(c.IMPORTEOUTROS,0) + COALESCE(c.IMPORTEPEDAGIO,0) +COALESCE(IMPORTETAXAEMBARQUE ,0)+COALESCE(c.preciopagado,0)) "); + sql.append(" ELSE 0 "); + sql.append(" END),0) AS valorEstornado, "); + sql.append(" COALESCE(COUNT( "); + sql.append(" CASE "); + sql.append(" WHEN c.MOTIVOCANCELACION_ID IS NOT NULL "); + sql.append(" AND c.MOTIVOCANCELACION_ID <> 31 "); + sql.append(" THEN 1 "); + sql.append(" ELSE NULL "); + sql.append(" END),0) AS qtdEstornado "); + sql.append(" "); + sql.append(" FROM CAJA c "); + sql.append(" INNER JOIN PUNTO_VENTA pv "); + sql.append(" ON c.PUNTOVENTA_ID = pv.PUNTOVENTA_ID "); + sql.append(" INNER JOIN marca m "); + sql.append(" ON m.marca_id = c.marca_id "); + sql.append(" WHERE c.TURNO_ID IS NOT NULL "); + sql.append(" AND c.FECCORTE BETWEEN :de AND :ate "); + if (puntoVenta != null && !puntoVenta.equals("-1")) { + sql.append(" AND c.PUNTOVENTA_ID in (" + puntoVenta + ") "); + } + sql.append(" AND c.TIPOVENTA_ID <> 6 "); + sql.append(" AND c.INDREIMPRESION = 0 "); + if (empresa != null && !empresa.equals("") && !empresa.equals("-1")) { + sql.append(" AND m.empresa_id = "+empresa+" "); + } + sql.append(" GROUP BY pv.PUNTOVENTA_ID, pv.nombpuntoventa "); + sql.append(" ORDER BY pv.nombpuntoventa "); + + return sql.toString(); + + } + + private String carregarEventosExtras(String puntoVenta, String empresa) { + + StringBuilder sql = new StringBuilder(); + sql.append(" SELECT "); + sql.append(" COALESCE(SUM(CASE WHEN tee.CVETIPOEVENTO = 'EXCESSO_BAGAGEM' THEN cd.PRECIO ELSE NULL END),0) AS valorExcesso, "); + sql.append(" COALESCE(COUNT(CASE WHEN tee.CVETIPOEVENTO = 'EXCESSO_BAGAGEM' THEN 1 ELSE NULL END),0) as qtdExcesso, "); + sql.append(" COALESCE(SUM(CASE WHEN tee.CVETIPOEVENTO = 'SEGURO_OPCIONAL' THEN cd.PRECIO ELSE NULL END),0) AS valorSeguro, "); + sql.append(" COALESCE(COUNT(CASE WHEN tee.CVETIPOEVENTO = 'SEGURO_OPCIONAL' THEN 1 ELSE NULL END),0) as qtdSeguro "); + sql.append(" FROM CAJA_DIVERSOS cd "); + sql.append(" INNER JOIN EVENTO_EXTRA ee "); + sql.append(" ON ee.EVENTOEXTRA_ID = cd.EVENTOEXTRA_ID "); + sql.append(" INNER JOIN TIPO_EVENTO_EXTRA tee "); + sql.append(" ON ee.TIPOEVENTOEXTRA_ID = tee.TIPOEVENTOEXTRA_ID "); + sql.append(" WHERE cd.MOTIVOCANCELACION_ID IS NULL "); + sql.append(" AND ee.activo = 1 "); + sql.append(" AND cd.TURNO_ID IS NOT NULL "); + sql.append(" AND tee.CVETIPOEVENTO in ('EXCESSO_BAGAGEM', 'SEGURO_OPCIONAL' ) "); + sql.append(" AND cd.FECCORTE BETWEEN :de AND :ate "); + if (puntoVenta != null && !puntoVenta.equals("-1")) { + sql.append(" AND cd.PUNTOVENTA_ID = ").append(puntoVenta); + } + if (empresa != null && !empresa.equals("") && !empresa.equals("-1")) { + sql.append(" AND ee.EMPRESA_ID = "+empresa+" "); + } + + + log.debug(sql.toString()); + + return sql.toString(); + + } + +} diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioAgenciaFechamentoResumo.java b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioAgenciaFechamentoResumo.java new file mode 100644 index 000000000..f60dec40d --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioAgenciaFechamentoResumo.java @@ -0,0 +1,80 @@ +package com.rjconsultores.ventaboletos.relatorios.impl; + +import java.sql.Connection; +import java.util.Map; + +public class RelatorioAgenciaFechamentoResumo extends RelatorioAgenciaFechamento { + + public RelatorioAgenciaFechamentoResumo(Map parametros, Connection conexao) throws Exception { + super(parametros, conexao); + tipoRelatorio = TipoRelatorioFechamentoEnum.RESUMO; + } + + @Override + protected String criarQueryReceitaDespesa(String puntoVenta, String empresa) { + + StringBuilder sql = new StringBuilder(); + sql.append(" SELECT "); + sql.append(" COALESCE(COUNT(CASE WHEN cdp.IMPORTE < 0 THEN 1 ELSE NULL END),0) as qtdedespesa, "); + sql.append(" COALESCE(SUM(CASE WHEN cdp.IMPORTE > 0 THEN cdp.IMPORTE ELSE NULL END),0) AS receita, "); + sql.append(" COALESCE(ABS(SUM(CASE WHEN cdp.IMPORTE < 0 THEN cdp.IMPORTE ELSE NULL END)),0) AS despesa "); + sql.append(" FROM CAJA_DIVERSOS cd, "); + sql.append(" CAJA_DIVERSOS_PAGO cdp, "); + sql.append(" EVENTO_EXTRA ee "); + sql.append(" WHERE cd.MOTIVOCANCELACION_ID IS NULL "); + sql.append(" AND ee.EVENTOEXTRA_ID = cd.EVENTOEXTRA_ID "); + sql.append(" AND cdp.CAJADIVERSOS_ID = cd.CAJADIVERSOS_ID "); + sql.append(" AND ee.activo = 1 "); + sql.append(" AND cd.TURNO_ID IS NOT NULL "); + sql.append(" AND cd.FECCORTE BETWEEN :de AND :ate "); + if (puntoVenta != null && !puntoVenta.equals("-1")) { + sql.append(" AND cd.PUNTOVENTA_ID = " + puntoVenta + " "); + } + if (empresa != null && !empresa.equals("") && !empresa.equals("-1")) { + sql.append(" AND ee.EMPRESA_ID = " + empresa + " "); + } + + return sql.toString(); + + } + + @Override + public StringBuilder carregarDados(String puntoVenta, String empresa) { + StringBuilder sql = new StringBuilder(); + sql.append(" SELECT "); + sql.append(" pv.NUMPUNTOVENTA AS codigo, "); + sql.append(" pv.nombpuntoventa AS descricao, "); + sql.append(" PV_GERENCIA.NUMPUNTOVENTA AS subordinado, "); + sql.append(" COALESCE(COUNT(CASE WHEN c.MOTIVOCANCELACION_ID IS NULL and (c.INDREMOTOINVERSO is null or c.INDREMOTOINVERSO =0) THEN c.caja_id ELSE NULL END),0) AS qtdevendido, "); + sql.append(" "); + sql.append(" COALESCE(COUNT(CASE WHEN c.INDREMOTOINVERSO = 1 THEN 1 ELSE NULL END),0) AS qtdedigitado, "); + sql.append(" "); + sql.append(" COALESCE(COUNT(CASE WHEN c.MOTIVOCANCELACION_ID = 31 THEN 1 ELSE NULL END),0) AS qtdeAnulado, "); + sql.append(" COALESCE(COUNT(CASE WHEN c.MOTIVOCANCELACION_ID is not null and c.MOTIVOCANCELACION_ID = 32 THEN 1 ELSE NULL END),0) AS qtdeDevolvido, "); + sql.append(" "); + sql.append(" COALESCE(SUM(CASE WHEN c.MOTIVOCANCELACION_ID IS NULL and (c.INDREMOTOINVERSO is null or c.INDREMOTOINVERSO =0) THEN ( "); + sql.append(" coalesce(c.IMPORTEOUTROS,0) + coalesce(c.IMPORTEPEDAGIO,0) + coalesce(c.IMPORTESEGURO,0) "); + sql.append(" +coalesce(IMPORTETAXAEMBARQUE ,0)+coalesce(c.preciopagado,0)) ELSE NULL END),0) AS vendido, "); + sql.append(" "); + sql.append(" COALESCE(SUM(CASE WHEN c.MOTIVOCANCELACION_ID IS NULL and c.INDREMOTOINVERSO = 1 THEN ( "); + sql.append(" coalesce(c.IMPORTEOUTROS,0) + coalesce(c.IMPORTEPEDAGIO,0) + coalesce(c.IMPORTESEGURO,0) "); + sql.append(" +coalesce(IMPORTETAXAEMBARQUE ,0)+coalesce(c.preciopagado,0)) ELSE NULL END),0) AS digitado, "); + sql.append(" "); + sql.append(" COALESCE(SUM(CASE WHEN c.MOTIVOCANCELACION_ID = 31 THEN ( "); + sql.append(" coalesce(c.IMPORTEOUTROS,0) + coalesce(c.IMPORTEPEDAGIO,0) + coalesce(c.IMPORTESEGURO,0) "); + sql.append(" +coalesce(IMPORTETAXAEMBARQUE ,0)+coalesce(c.preciopagado,0)) ELSE NULL END),0) AS anulado, "); + sql.append(" "); + sql.append(" COALESCE(SUM(CASE WHEN c.MOTIVOCANCELACION_ID is not null and c.MOTIVOCANCELACION_ID = 32 THEN ( "); + sql.append(" coalesce(c.IMPORTEOUTROS,0) + coalesce(c.IMPORTEPEDAGIO,0) + coalesce(c.IMPORTESEGURO,0) "); + sql.append(" +coalesce(IMPORTETAXAEMBARQUE ,0)+coalesce(c.preciopagado,0)) ELSE NULL END),0) AS devolvido, "); + sql.append(" pv.PUNTOVENTA_ID AS puntoventaId "); + return sql; + } + + @Override + protected void criarGroupByEOrderBy(StringBuilder sql) { + sql.append(" GROUP BY pv.NUMPUNTOVENTA , pv.nombpuntoventa, pv.puntoventa_id, PV_GERENCIA.NUMPUNTOVENTA "); + sql.append(" ORDER BY pv.nombpuntoventa "); + } + +} diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioAgenciaFechamentoResumoDiario.java b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioAgenciaFechamentoResumoDiario.java deleted file mode 100644 index fa70d32aa..000000000 --- a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioAgenciaFechamentoResumoDiario.java +++ /dev/null @@ -1,262 +0,0 @@ -package com.rjconsultores.ventaboletos.relatorios.impl; - -import java.math.BigDecimal; -import java.sql.Connection; -import java.sql.ResultSet; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.apache.commons.lang.math.NumberUtils; - -import com.rjconsultores.ventaboletos.relatorios.utilitarios.DataSource; -import com.rjconsultores.ventaboletos.relatorios.utilitarios.Relatorio; -import com.rjconsultores.ventaboletos.relatorios.utilitarios.RelatorioAgenciaFechamentoAntigoBean; -import com.rjconsultores.ventaboletos.web.utilerias.NamedParameterStatement; - -import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource; - -public class RelatorioAgenciaFechamentoResumoDiario extends Relatorio { - - private List lsDadosRelatorio; - - public RelatorioAgenciaFechamentoResumoDiario(Map parametros, Connection conexao) throws Exception { - super(parametros, conexao); - - this.setCustomDataSource(new DataSource(this) { - @Override - public void initDados() throws Exception { - - Connection conexao = this.relatorio.getConexao(); - - Map parametros = this.relatorio.getParametros(); - - String fecInicio = parametros.get("fecInicio").toString() + " 00:00:00"; - String fecFinal = parametros.get("fecFinal").toString() + " 23:59:59"; - String empresa = parametros.get("empresa") != null ? parametros.get("empresa").toString() : ""; - String empresaNome = parametros.get("empresaNome") != null ? parametros.get("empresaNome").toString() : ""; - String puntoVenta = parametros.get("NUMPUNTOVENTA") != null ? parametros.get("NUMPUNTOVENTA").toString() : null; - - lsDadosRelatorio = new ArrayList(); - - String sql = carregarDadosTotaisdeVenda(puntoVenta, empresa); - - System.out.println(sql); - - NamedParameterStatement stmt = new NamedParameterStatement(conexao, sql); - ResultSet rset1 = null; - ResultSet rset2 = null; - SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss"); - - stmt.setTimestamp("de", new java.sql.Timestamp(sdf.parse(fecInicio).getTime())); - stmt.setTimestamp("ate", new java.sql.Timestamp(sdf.parse(fecFinal).getTime())); - - rset1= stmt.executeQuery(); - - while (rset1.next()) { - - RelatorioAgenciaFechamentoAntigoBean agenciaFechamento = new RelatorioAgenciaFechamentoAntigoBean(); - BigDecimal total = BigDecimal.ZERO; - BigDecimal vendido = BigDecimal.ZERO; - - String puntoVentaId = rset1.getString("puntoventaId"); - - Integer qtdevendido = rset1.getInt("qtdevendido"); - Integer qtdedigitado = rset1.getInt("qtdedigitado"); - Integer qtdeAnulado = rset1.getInt("qtdeAnulado"); - Integer qtdeDevolvido = rset1.getInt("qtdeDevolvido"); - Integer qtdeTotal = null; - - vendido = rset1.getBigDecimal("vendido"); - BigDecimal digitado = rset1.getBigDecimal("digitado"); - BigDecimal anulado = rset1.getBigDecimal("anulado"); - BigDecimal devolvido = rset1.getBigDecimal("devolvido"); - - agenciaFechamento.setEmpresa(empresaNome); - - agenciaFechamento.setCodigo(rset1.getString("codigo")); - agenciaFechamento.setDescricao(rset1.getString("descricao")); - - agenciaFechamento.setQtdeVendido(qtdevendido != null ? qtdevendido : NumberUtils.INTEGER_ZERO); - agenciaFechamento.setQtdeDigitado(qtdedigitado != null ? qtdedigitado : NumberUtils.INTEGER_ZERO); - agenciaFechamento.setQtdeAnulado(qtdeAnulado != null ? qtdeAnulado : NumberUtils.INTEGER_ZERO); - agenciaFechamento.setQtdeDevolvido(qtdeDevolvido != null ? qtdeDevolvido : NumberUtils.INTEGER_ZERO); - - qtdeTotal = ((qtdevendido != null ? qtdevendido : NumberUtils.INTEGER_ZERO) + (qtdedigitado != null ? qtdedigitado : NumberUtils.INTEGER_ZERO)) - - ((qtdeAnulado != null ? qtdeAnulado : NumberUtils.INTEGER_ZERO) + (qtdeDevolvido != null ? qtdeDevolvido : NumberUtils.INTEGER_ZERO)); - - if (qtdeTotal < 0) { - qtdeTotal = NumberUtils.INTEGER_ZERO; - } - - agenciaFechamento.setQtdeTotal(qtdeTotal); - - agenciaFechamento.setDigitado(digitado != null ? digitado : BigDecimal.ZERO); - agenciaFechamento.setAnulado(anulado != null ? anulado : BigDecimal.ZERO); - agenciaFechamento.setDevolvido(devolvido != null ? devolvido : BigDecimal.ZERO); - - total = total.add(vendido != null ? vendido : BigDecimal.ZERO); - total = total.add(digitado != null ? digitado : BigDecimal.ZERO); - total = total.subtract(anulado != null ? anulado : BigDecimal.ZERO); - total = total.subtract(devolvido != null ? devolvido : BigDecimal.ZERO); - - String strQueryReceitaDespesa = carregarDadosReceitaDespesa(puntoVentaId, empresa); - stmt = new NamedParameterStatement(conexao, strQueryReceitaDespesa); - - stmt.setTimestamp("de", new java.sql.Timestamp(sdf.parse(fecInicio).getTime())); - stmt.setTimestamp("ate", new java.sql.Timestamp(sdf.parse(fecFinal).getTime())); - - rset2 = stmt.executeQuery(); - - if (rset2.next()) { - - Integer qtdedespesa = rset2.getInt("qtdedespesa"); - BigDecimal receita = rset2.getBigDecimal("receita"); - BigDecimal despesa = rset2.getBigDecimal("despesa"); - - agenciaFechamento.setQtdeDespesa(qtdedespesa != null ? qtdedespesa : NumberUtils.INTEGER_ZERO); - agenciaFechamento.setReceita(receita != null ? receita : BigDecimal.ZERO); - agenciaFechamento.setDespesa(despesa != null ? despesa : BigDecimal.ZERO); - - total = total.add(receita != null ? receita : BigDecimal.ZERO); - total = total.subtract(despesa != null ? despesa : BigDecimal.ZERO); - - agenciaFechamento.setVendido(vendido != null ? vendido : BigDecimal.ZERO); - agenciaFechamento.setTotal(total); - - } else { - agenciaFechamento.setQtdeDespesa(NumberUtils.INTEGER_ZERO); - agenciaFechamento.setReceita(BigDecimal.ZERO); - agenciaFechamento.setDespesa(BigDecimal.ZERO); - agenciaFechamento.setVendido(vendido != null ? vendido : BigDecimal.ZERO); - agenciaFechamento.setTotal(total); - } - - lsDadosRelatorio.add(agenciaFechamento); - //Estava dando um erro de "máximo de cursores abertos excedido" - //Colocado isso o erro parou de ocorrer - rset2.getStatement().close(); - rset2.close(); - } - - if (lsDadosRelatorio.size() > 0) { - - setLsDadosRelatorio(lsDadosRelatorio); - } - - } - }); - } - - public void setLsDadosRelatorio(List lsDadosRelatorio) { - this.setCollectionDataSource(new JRBeanCollectionDataSource(lsDadosRelatorio)); - this.lsDadosRelatorio = lsDadosRelatorio; - } - - @Override - protected void processaParametros() throws Exception { - } - - private String carregarDadosTotaisdeVenda(String puntoVenta, String empresa) { - - StringBuilder sql = new StringBuilder(); - sql.append(" SELECT "); - sql.append(" pv.NUMPUNTOVENTA AS codigo, "); - sql.append(" pv.nombpuntoventa AS descricao, "); - sql.append(" "); - sql.append(" COALESCE(COUNT(CASE WHEN c.MOTIVOCANCELACION_ID IS NULL and (c.INDREMOTOINVERSO is null or c.INDREMOTOINVERSO =0) THEN c.caja_id ELSE NULL END),0) AS qtdevendido, "); - sql.append(" "); - sql.append(" COALESCE(COUNT(CASE WHEN c.INDREMOTOINVERSO = 1 THEN 1 ELSE NULL END),0) AS qtdedigitado, "); - sql.append(" "); - sql.append(" COALESCE(COUNT(CASE WHEN c.MOTIVOCANCELACION_ID = 31 THEN 1 ELSE NULL END),0) AS qtdeAnulado, "); - sql.append(" COALESCE(COUNT(CASE WHEN c.MOTIVOCANCELACION_ID is not null and c.MOTIVOCANCELACION_ID = 32 THEN 1 ELSE NULL END),0) AS qtdeDevolvido, "); - sql.append(" "); - sql.append(" COALESCE(SUM(CASE WHEN c.MOTIVOCANCELACION_ID IS NULL and (c.INDREMOTOINVERSO is null or c.INDREMOTOINVERSO =0) THEN ( "); - sql.append(" coalesce(c.IMPORTEOUTROS,0) + coalesce(c.IMPORTEPEDAGIO,0) + coalesce(c.IMPORTESEGURO,0) "); - sql.append(" +coalesce(IMPORTETAXAEMBARQUE ,0)+coalesce(c.preciopagado,0)) ELSE NULL END),0) AS vendido, "); - sql.append(" "); - sql.append(" COALESCE(SUM(CASE WHEN c.MOTIVOCANCELACION_ID IS NULL and c.INDREMOTOINVERSO = 1 THEN ( "); - sql.append(" coalesce(c.IMPORTEOUTROS,0) + coalesce(c.IMPORTEPEDAGIO,0) + coalesce(c.IMPORTESEGURO,0) "); - sql.append(" +coalesce(IMPORTETAXAEMBARQUE ,0)+coalesce(c.preciopagado,0)) ELSE NULL END),0) AS digitado, "); - sql.append(" "); - sql.append(" COALESCE(SUM(CASE WHEN c.MOTIVOCANCELACION_ID = 31 THEN ( "); - sql.append(" coalesce(c.IMPORTEOUTROS,0) + coalesce(c.IMPORTEPEDAGIO,0) + coalesce(c.IMPORTESEGURO,0) "); - sql.append(" +coalesce(IMPORTETAXAEMBARQUE ,0)+coalesce(c.preciopagado,0)) ELSE NULL END),0) AS anulado, "); - sql.append(" "); - sql.append(" COALESCE(SUM(CASE WHEN c.MOTIVOCANCELACION_ID is not null and c.MOTIVOCANCELACION_ID = 32 THEN ( "); - sql.append(" coalesce(c.IMPORTEOUTROS,0) + coalesce(c.IMPORTEPEDAGIO,0) + coalesce(c.IMPORTESEGURO,0) "); - sql.append(" +coalesce(IMPORTETAXAEMBARQUE ,0)+coalesce(c.preciopagado,0)) ELSE NULL END),0) AS devolvido, "); - sql.append(" pv.PUNTOVENTA_ID AS puntoventaId "); - sql.append(" "); - sql.append(" FROM CAJA c "); - sql.append(" INNER JOIN PUNTO_VENTA pv ON c.PUNTOVENTA_ID = pv.PUNTOVENTA_ID "); - sql.append(" inner join marca m on m.marca_id = c.marca_id "); - sql.append(" WHERE c.TURNO_ID IS NOT NULL "); - sql.append(" AND c.FECCORTE BETWEEN :de AND :ate "); - if (puntoVenta != null && !puntoVenta.equals("-1")) { - sql.append(" AND c.PUNTOVENTA_ID in (" + puntoVenta + ") "); - } - sql.append(" AND c.TIPOVENTA_ID <> 6 "); - sql.append(" AND c.INDREIMPRESION = 0 "); - if (empresa != null && !empresa.equals("") && !empresa.equals("-1")) { - sql.append(" AND m.empresa_id = "+empresa+" "); - } - sql.append(" GROUP BY pv.NUMPUNTOVENTA , pv.nombpuntoventa, pv.puntoventa_id "); - sql.append(" ORDER BY pv.NUMPUNTOVENTA , pv.nombpuntoventa "); - - return sql.toString(); - - } - - private String carregaAgenciasComVenda() { - - StringBuilder sql = new StringBuilder(); - sql.append(" SELECT DISTINCT cc.PUNTOVENTA_ID "); - sql.append(" FROM CONTA_CORRENTE_PTOVTA cc "); - sql.append(" WHERE cc.FECHOROPERACION BETWEEN :de AND :ate "); - sql.append(" and cc.EMPRESA_ID = :empresaId "); - - return sql.toString(); - - } - - private String carregarDadosReceitaDespesa(String puntoVenta, String empresa) { - - StringBuilder sql = new StringBuilder(); - sql.append(" SELECT "); - sql.append(" COALESCE(COUNT(CASE WHEN cdp.IMPORTE < 0 THEN 1 ELSE NULL END),0) as qtdedespesa, "); - sql.append(" COALESCE(SUM(CASE WHEN cdp.IMPORTE > 0 THEN cdp.IMPORTE ELSE NULL END),0) AS receita, "); - sql.append(" COALESCE(ABS(SUM(CASE WHEN cdp.IMPORTE < 0 THEN cdp.IMPORTE ELSE NULL END)),0) AS despesa "); - sql.append(" FROM CAJA_DIVERSOS cd, "); - sql.append(" CAJA_DIVERSOS_PAGO cdp, "); - sql.append(" EVENTO_EXTRA ee "); - sql.append(" WHERE cd.MOTIVOCANCELACION_ID IS NULL "); - sql.append(" AND ee.EVENTOEXTRA_ID = cd.EVENTOEXTRA_ID "); - sql.append(" AND cdp.CAJADIVERSOS_ID = cd.CAJADIVERSOS_ID "); - sql.append(" AND ee.activo = 1 "); - sql.append(" AND cd.TURNO_ID IS NOT NULL "); - sql.append(" AND cd.FECCORTE BETWEEN :de AND :ate "); - if (puntoVenta != null && !puntoVenta.equals("-1")) { - sql.append(" AND cd.PUNTOVENTA_ID = "+puntoVenta+" "); - } - if (empresa != null && !empresa.equals("") && !empresa.equals("-1")) { - sql.append(" AND ee.EMPRESA_ID = "+empresa+" "); - } - - return sql.toString(); - - } - - private String carregarNomeEmpresa() { - - StringBuilder sql = new StringBuilder(); - sql.append(" SELECT "); - sql.append(" NOMBEMPRESA "); - sql.append(" FROM EMPRESA "); - sql.append(" WHERE EMPRESA_ID=:empresaId "); - - return sql.toString(); - - } -} diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/TipoRelatorioFechamentoEnum.java b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/TipoRelatorioFechamentoEnum.java new file mode 100644 index 000000000..591098d4e --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/TipoRelatorioFechamentoEnum.java @@ -0,0 +1,10 @@ +package com.rjconsultores.ventaboletos.relatorios.impl; + +public enum TipoRelatorioFechamentoEnum { + + NOVO, + ANTIGO, + RESUMO, + DIARIO; + +} diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioAgenciaFechamentoDiario_es.properties b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioAgenciaFechamentoDiario_es.properties new file mode 100644 index 000000000..6b19c9a95 --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioAgenciaFechamentoDiario_es.properties @@ -0,0 +1,25 @@ +#geral +msg.noData=No se pudo obtener datos con los parámetros reportados. +msg.a=a + +#Labels header +header.data=Data : +header.empresa=Empresa : +header.codigo=Código +header.descricao=Descrição +header.vendido=Vendido +header.digitado=Digitado +header.anulado=Anulados +header.devolvido=Devolvidos +header.receita=Receita +header.despesa=Despesa +header.total=Total +header.dataCorte=Data +header.subordinado=Subordinado + +detail.agencia=AGÊNCIA +detail.quantidade=QUANTIDADE +detail.valor=VALOR +detail.totalGeral=TOTAL GERAL + +linhas=Linhas \ No newline at end of file diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioAgenciaFechamentoResumoDiario_es.properties b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioAgenciaFechamentoDiario_pt_BR.properties similarity index 69% rename from src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioAgenciaFechamentoResumoDiario_es.properties rename to src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioAgenciaFechamentoDiario_pt_BR.properties index d57b22ac6..6a8b4335e 100644 --- a/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioAgenciaFechamentoResumoDiario_es.properties +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioAgenciaFechamentoDiario_pt_BR.properties @@ -1,12 +1,12 @@ -#geral +#geral msg.noData=No se pudo obtener datos con los parámetros reportados. msg.a=a #Labels header header.data=Data : header.empresa=Empresa : -header.codigo=Código -header.descricao=Descrição +header.codigo=Código +header.descricao=Descrição header.vendido=Vendido header.digitado=Digitado header.anulado=Anulados @@ -14,8 +14,10 @@ header.devolvido=Devolvidos header.receita=Receita header.despesa=Despesa header.total=Total +header.dataCorte=Data +header.subordinado=Subordinado -detail.agencia=AGÊNCIA +detail.agencia=AGÊNCIA detail.quantidade=QUANTIDADE detail.valor=VALOR detail.totalGeral=TOTAL GERAL diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioAgenciaFechamento_es.properties b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioAgenciaFechamentoNovo_es.properties similarity index 100% rename from src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioAgenciaFechamento_es.properties rename to src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioAgenciaFechamentoNovo_es.properties diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioAgenciaFechamento_pt_BR.properties b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioAgenciaFechamentoNovo_pt_BR.properties similarity index 100% rename from src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioAgenciaFechamento_pt_BR.properties rename to src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioAgenciaFechamentoNovo_pt_BR.properties diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioAgenciaFechamentoResumo_es.properties b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioAgenciaFechamentoResumo_es.properties new file mode 100644 index 000000000..7827b9cb8 --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioAgenciaFechamentoResumo_es.properties @@ -0,0 +1,24 @@ +#geral +msg.noData=No se pudo obtener datos con los parámetros reportados. +msg.a=a + +#Labels header +header.data=Data : +header.empresa=Empresa : +header.codigo=Código +header.descricao=Descrição +header.vendido=Vendido +header.digitado=Digitado +header.anulado=Anulados +header.devolvido=Devolvidos +header.receita=Receita +header.despesa=Despesa +header.total=Total +header.subordinado=Subordinado + +detail.agencia=AGÊNCIA +detail.quantidade=QUANTIDADE +detail.valor=VALOR +detail.totalGeral=TOTAL GERAL + +linhas=Linhas \ No newline at end of file diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioAgenciaFechamentoResumoDiario_pt_BR.properties b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioAgenciaFechamentoResumo_pt_BR.properties similarity index 87% rename from src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioAgenciaFechamentoResumoDiario_pt_BR.properties rename to src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioAgenciaFechamentoResumo_pt_BR.properties index 3aa97e55b..7012c57f2 100644 --- a/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioAgenciaFechamentoResumoDiario_pt_BR.properties +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioAgenciaFechamentoResumo_pt_BR.properties @@ -14,6 +14,7 @@ header.devolvido=Devolvidos header.receita=Receita header.despesa=Despesa header.total=Total +header.subordinado=Subordinado detail.agencia=AGÊNCIA detail.quantidade=QUANTIDADE diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioAgenciaFechamento.jasper b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioAgenciaFechamento.jasper deleted file mode 100644 index ef60d8b67..000000000 Binary files a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioAgenciaFechamento.jasper and /dev/null differ diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioAgenciaFechamentoAntigo.jasper b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioAgenciaFechamentoAntigo.jasper index 7f7a686d9..f9da5481c 100644 Binary files a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioAgenciaFechamentoAntigo.jasper and b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioAgenciaFechamentoAntigo.jasper differ diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioAgenciaFechamentoAntigo.jrxml b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioAgenciaFechamentoAntigo.jrxml index bc32bbbee..48611d9d2 100644 --- a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioAgenciaFechamentoAntigo.jrxml +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioAgenciaFechamentoAntigo.jrxml @@ -1,5 +1,5 @@ - + diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioAgenciaFechamentoDiario.jasper b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioAgenciaFechamentoDiario.jasper new file mode 100644 index 000000000..0142b47fd Binary files /dev/null and b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioAgenciaFechamentoDiario.jasper differ diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioAgenciaFechamentoDiario.jrxml b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioAgenciaFechamentoDiario.jrxml new file mode 100644 index 000000000..b9a389cf8 --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioAgenciaFechamentoDiario.jrxml @@ -0,0 +1,526 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioAgenciaFechamentoNovo.jasper b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioAgenciaFechamentoNovo.jasper new file mode 100644 index 000000000..6d8744be3 Binary files /dev/null and b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioAgenciaFechamentoNovo.jasper differ diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioAgenciaFechamento.jrxml b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioAgenciaFechamentoNovo.jrxml similarity index 65% rename from src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioAgenciaFechamento.jrxml rename to src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioAgenciaFechamentoNovo.jrxml index fe2003bd3..45eb76bdc 100644 --- a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioAgenciaFechamento.jrxml +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioAgenciaFechamentoNovo.jrxml @@ -1,5 +1,5 @@ - + @@ -80,170 +80,171 @@ - + - + + - + - + + - + + - - - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -254,105 +255,105 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -363,108 +364,108 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -475,7 +476,8 @@ - + + diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioAgenciaFechamentoResumo.jasper b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioAgenciaFechamentoResumo.jasper new file mode 100644 index 000000000..3fdb078cb Binary files /dev/null and b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioAgenciaFechamentoResumo.jasper differ diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioAgenciaFechamentoResumoDiario.jrxml b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioAgenciaFechamentoResumo.jrxml similarity index 90% rename from src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioAgenciaFechamentoResumoDiario.jrxml rename to src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioAgenciaFechamentoResumo.jrxml index ad7869646..d0c58657f 100644 --- a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioAgenciaFechamentoResumoDiario.jrxml +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioAgenciaFechamentoResumo.jrxml @@ -1,5 +1,5 @@ - + @@ -31,6 +31,7 @@ + @@ -160,105 +161,105 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -270,115 +271,131 @@ + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + + + diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioAgenciaFechamentoResumoDiario.jasper b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioAgenciaFechamentoResumoDiario.jasper deleted file mode 100644 index ed98b8d91..000000000 Binary files a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioAgenciaFechamentoResumoDiario.jasper and /dev/null differ diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/utilitarios/RelatorioAgenciaFechamentoAntigoBean.java b/src/java/com/rjconsultores/ventaboletos/relatorios/utilitarios/RelatorioAgenciaFechamentoAntigoBean.java index eb1983c99..c823e7690 100644 --- a/src/java/com/rjconsultores/ventaboletos/relatorios/utilitarios/RelatorioAgenciaFechamentoAntigoBean.java +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/utilitarios/RelatorioAgenciaFechamentoAntigoBean.java @@ -1,6 +1,7 @@ package com.rjconsultores.ventaboletos.relatorios.utilitarios; import java.math.BigDecimal; +import java.util.Date; public class RelatorioAgenciaFechamentoAntigoBean { protected String empresa; @@ -20,6 +21,8 @@ public class RelatorioAgenciaFechamentoAntigoBean { protected BigDecimal receita; protected BigDecimal despesa; protected BigDecimal total; + protected Date data; + protected String subordinado; public String getEmpresa() { return empresa; @@ -119,5 +122,17 @@ public class RelatorioAgenciaFechamentoAntigoBean { public void setTotal(BigDecimal total) { this.total = total; } + public Date getData() { + return data; + } + public void setData(Date data) { + this.data = data; + } + public String getSubordinado() { + return subordinado; + } + public void setSubordinado(String subordinado) { + this.subordinado = subordinado; + } } diff --git a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioAgenciaFechamentoController.java b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioAgenciaFechamentoController.java index 33d959eac..ab3944788 100644 --- a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioAgenciaFechamentoController.java +++ b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioAgenciaFechamentoController.java @@ -24,9 +24,10 @@ import org.zkoss.zul.Radio; import com.rjconsultores.ventaboletos.entidad.Empresa; import com.rjconsultores.ventaboletos.entidad.PuntoVenta; -import com.rjconsultores.ventaboletos.relatorios.impl.RelatorioAgenciaFechamento; import com.rjconsultores.ventaboletos.relatorios.impl.RelatorioAgenciaFechamentoAntigo; -import com.rjconsultores.ventaboletos.relatorios.impl.RelatorioAgenciaFechamentoResumoDiario; +import com.rjconsultores.ventaboletos.relatorios.impl.RelatorioAgenciaFechamentoDiario; +import com.rjconsultores.ventaboletos.relatorios.impl.RelatorioAgenciaFechamentoNovo; +import com.rjconsultores.ventaboletos.relatorios.impl.RelatorioAgenciaFechamentoResumo; import com.rjconsultores.ventaboletos.relatorios.utilitarios.Relatorio; import com.rjconsultores.ventaboletos.service.EmpresaService; import com.rjconsultores.ventaboletos.web.utilerias.MyComboboxEstandar; @@ -62,14 +63,14 @@ public class RelatorioAgenciaFechamentoController extends MyGenericForwardCompos private Radio radLayoutNovo; private Radio radLayoutAntigo; - private Radio radLayoutResumoDiario; + private Radio radLayoutDiario; + private Radio radLayoutResumo; private List lsEmpresas; private void executarRelatorio() throws Exception { Map parametros = new HashMap(); - Boolean booleanLayout = false; Empresa empresa = cmbEmpresa.getSelectedItem() != null ? (Empresa)cmbEmpresa.getSelectedItem().getValue() : null; SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); @@ -102,15 +103,18 @@ public class RelatorioAgenciaFechamentoController extends MyGenericForwardCompos Relatorio relatorio; Map args = new HashMap(); if (radLayoutNovo.isChecked()) { - relatorio = new RelatorioAgenciaFechamento(parametros, dataSourceRead.getConnection()); + relatorio = new RelatorioAgenciaFechamentoNovo(parametros, dataSourceRead.getConnection()); args.put("relatorio", relatorio); }else if (radLayoutAntigo.isChecked()){ relatorio = new RelatorioAgenciaFechamentoAntigo(parametros, dataSourceRead.getConnection()); args.put("relatorio", relatorio); + } else if(radLayoutDiario.isChecked()) { + relatorio = new RelatorioAgenciaFechamentoDiario(parametros, dataSourceRead.getConnection()); + args.put("relatorio", relatorio); } else { - relatorio = new RelatorioAgenciaFechamentoResumoDiario(parametros, dataSourceRead.getConnection()); + relatorio = new RelatorioAgenciaFechamentoResumo(parametros, dataSourceRead.getConnection()); args.put("relatorio", relatorio); } @@ -208,11 +212,11 @@ public class RelatorioAgenciaFechamentoController extends MyGenericForwardCompos this.radLayoutAntigo = radLayoutAntigo; } - public Radio getRadLayoutResumoDiario() { - return radLayoutResumoDiario; + public Radio getRadLayoutDiario() { + return radLayoutDiario; } - public void setRadLayoutResumoDiario(Radio radLayoutResumoDiario) { - this.radLayoutResumoDiario = radLayoutResumoDiario; + public void setRadLayoutDiario(Radio radLayoutDiario) { + this.radLayoutDiario = radLayoutDiario; } } diff --git a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioAgenciasNaoImportadasController.java b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioAgenciasNaoImportadasController.java index 6ca9b19f3..969831596 100644 --- a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioAgenciasNaoImportadasController.java +++ b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioAgenciasNaoImportadasController.java @@ -1,10 +1,7 @@ package com.rjconsultores.ventaboletos.web.gui.controladores.relatorios; import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; -import java.util.List; import java.util.Map; import javax.sql.DataSource; @@ -14,27 +11,12 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Controller; import org.zkoss.util.resource.Labels; -import org.zkoss.zhtml.Messagebox; -import org.zkoss.zk.ui.Component; import org.zkoss.zk.ui.event.Event; -import org.zkoss.zul.Bandbox; import org.zkoss.zul.Datebox; -import org.zkoss.zul.Paging; -import com.rjconsultores.ventaboletos.entidad.Empresa; -import com.rjconsultores.ventaboletos.entidad.PuntoVenta; -import com.rjconsultores.ventaboletos.relatorios.impl.RelatorioAgenciaFechamento; import com.rjconsultores.ventaboletos.relatorios.impl.RelatorioAgenciasNaoImportadas; import com.rjconsultores.ventaboletos.relatorios.utilitarios.Relatorio; -import com.rjconsultores.ventaboletos.service.EmpresaService; -import com.rjconsultores.ventaboletos.web.utilerias.MyComboboxEstandar; import com.rjconsultores.ventaboletos.web.utilerias.MyGenericForwardComposer; -import com.rjconsultores.ventaboletos.web.utilerias.MyListbox; -import com.rjconsultores.ventaboletos.web.utilerias.MyTextbox; -import com.rjconsultores.ventaboletos.web.utilerias.paginacion.HibernateSearchObject; -import com.rjconsultores.ventaboletos.web.utilerias.paginacion.PagedListWrapper; -import com.rjconsultores.ventaboletos.web.utilerias.render.RenderRelatorioVendasBilheteiro; -import com.rjconsultores.ventaboletos.web.utilerias.render.RenderRelatorioVendasBilheteiroSelecionados; @Controller("relatorioAgenciasNaoImportadasController") @Scope("prototype") diff --git a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioController.java b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioController.java index ca8456fb5..3258f590e 100644 --- a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioController.java +++ b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioController.java @@ -97,7 +97,7 @@ public class RelatorioController extends MyGenericForwardComposer { try { this.relatorio = (Relatorio) Executions.getCurrent().getArg().get("relatorio"); - if (relatorio.getInfoMsg().size() > 0) { + if (!relatorio.getInfoMsg().isEmpty()) { String msg = ""; for (String msgItem : relatorio.getInfoMsg()) msg = msg.concat(msgItem + "\n"); diff --git a/web/WEB-INF/i3-label_es_MX.label b/web/WEB-INF/i3-label_es_MX.label index d553e1cc8..20735a4d3 100644 --- a/web/WEB-INF/i3-label_es_MX.label +++ b/web/WEB-INF/i3-label_es_MX.label @@ -788,7 +788,8 @@ relatorioVendasBilheteiroController.lbBilheteiro.value = Agente de Pasajes relatorioVendasBilheteiroController.lbLayout.value = Layout relatorioVendasBilheteiroController.lbLayoutNovo.value = Novo relatorioVendasBilheteiroController.lbLayoutAntigo.value = Antigo -relatorioVendasBilheteiroController.lbLayoutResumoDiario.value = Resumo Diário +relatorioVendasBilheteiroController.lbLayoutDiario.value = Diario +relatorioVendasBilheteiroController.lbLayoutResumo.value = Resumo #Relatório de Vendas por bilheteiro Sintético relatorioVendasBilheteiroSinteticoController.window.title = Reporte de ventas por agentes sintético diff --git a/web/WEB-INF/i3-label_pt_BR.label b/web/WEB-INF/i3-label_pt_BR.label index ecde1046f..cae39e735 100644 --- a/web/WEB-INF/i3-label_pt_BR.label +++ b/web/WEB-INF/i3-label_pt_BR.label @@ -830,7 +830,8 @@ relatorioVendasBilheteiroController.lbBilheteiro.value = Bilheteiro relatorioVendasBilheteiroController.lbLayout.value = Layout relatorioVendasBilheteiroController.lbLayoutNovo.value = Novo relatorioVendasBilheteiroController.lbLayoutAntigo.value = Antigo -relatorioVendasBilheteiroController.lbLayoutResumoDiario.value = Resumo Diário +relatorioVendasBilheteiroController.lbLayoutDiario.value = Diário +relatorioVendasBilheteiroController.lbLayoutResumo.value = Resumo #Relatório de Vendas por bilheteiro Sintético relatorioVendasBilheteiroSinteticoController.window.title = Relatório de Vendas por Bilheteiro Sintético diff --git a/web/gui/relatorios/filtroRelatorioAgenciaFechamento.zul b/web/gui/relatorios/filtroRelatorioAgenciaFechamento.zul index 775124ecb..8792bebce 100644 --- a/web/gui/relatorios/filtroRelatorioAgenciaFechamento.zul +++ b/web/gui/relatorios/filtroRelatorioAgenciaFechamento.zul @@ -7,8 +7,8 @@ + contentStyle="overflow:auto" height="283px" width="800px" + border="normal" sizable="true"> @@ -82,7 +82,8 @@ - + +