diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioVendasBilheteiroSintetico.java b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioVendasBilheteiroSintetico.java index 890b664db..347d3236c 100644 --- a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioVendasBilheteiroSintetico.java +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioVendasBilheteiroSintetico.java @@ -21,7 +21,6 @@ import com.rjconsultores.ventaboletos.web.utilerias.NamedParameterStatement; */ public class RelatorioVendasBilheteiroSintetico extends Relatorio { - public RelatorioVendasBilheteiroSintetico(Map parametros, Connection conexao) throws Exception { super(parametros, conexao); @@ -31,23 +30,80 @@ public class RelatorioVendasBilheteiroSintetico extends Relatorio { Connection conexao = this.relatorio.getConexao(); Map parametros = this.relatorio.getParametros(); - StringBuilder sql = new StringBuilder(); - + sql.append("select "); sql.append(" pv.NUMPUNTOVENTA, us.cveusuario , us.NOMBUSUARIO, tpv.DESCTIPO,"); sql.append(" sum (case when ca.motivocancelacion_id is null then 1 else 0 end) qtdVendas, "); sql.append(" sum (case when ca.motivocancelacion_id is null then "); - sql.append(" (coalesce(ca.preciopagado,0) "); - sql.append(" + coalesce(ca.importepedagio,0) "); - sql.append(" + coalesce(ca.importetaxaembarque,0) "); - sql.append(" + coalesce(ca.importeseguro,0) ) else 0 end ) vlrVendas, "); + + + Boolean soma = false; + sql.append(" ("); + if (parametros.get("TARIFA") != null) { + soma = true; + sql.append(" coalesce(ca.preciopagado,0) "); + } + if (parametros.get("PEDAGIO") != null) { + if (soma) { + sql.append(" + coalesce(ca.importepedagio,0) "); + } else { + sql.append(" coalesce(ca.importepedagio,0) "); + soma = true; + } + } + if (parametros.get("TAXADEEMBARQUE") != null) { + if (soma) { + sql.append(" + coalesce(ca.importetaxaembarque,0) "); + } else { + sql.append(" coalesce(ca.importetaxaembarque,0) "); + soma = true; + } + } + if (parametros.get("SEGURO") != null) { + if (soma) { + sql.append(" + coalesce(ca.importeseguro,0) "); + } else { + sql.append(" coalesce(ca.importeseguro,0) "); + } + } + sql.append(" ) else 0 end ) vlrVendas, "); + sql.append(" sum (case when ca.motivocancelacion_id is not null then 1 else 0 end) qtdCancelados, "); sql.append(" sum (case when ca.motivocancelacion_id is not null then "); - sql.append(" (coalesce(ca.preciopagado,0) "); - sql.append(" + coalesce(ca.importepedagio,0) "); - sql.append(" + coalesce(ca.importetaxaembarque,0) "); - sql.append(" + coalesce(ca.importeseguro,0) ) else 0 end ) vlrCancelados "); + + soma = false; + sql.append(" ("); + if (parametros.get("TARIFA") != null) { + sql.append(" coalesce(ca.preciopagado,0) "); + soma = true; + } + if (parametros.get("PEDAGIO") != null) { + if (soma) { + sql.append(" + coalesce(ca.importepedagio,0) "); + } else { + sql.append(" coalesce(ca.importepedagio,0) "); + soma = true; + } + } + if (parametros.get("TAXADEEMBARQUE") != null) { + if (soma) { + sql.append(" + coalesce(ca.importetaxaembarque,0) "); + } else { + sql.append(" coalesce(ca.importetaxaembarque,0) "); + soma = true; + } + } + if (parametros.get("SEGURO") != null) { + if (soma) { + sql.append(" + coalesce(ca.importeseguro,0) "); + } else { + sql.append(" coalesce(ca.importeseguro,0) "); + } + } + sql.append(" ) else 0 end ) vlrCancelados "); + + sql.append("from "); sql.append(" caja ca "); sql.append(" inner join usuario us on us.usuario_id = ca.usuario_id "); @@ -58,31 +114,30 @@ public class RelatorioVendasBilheteiroSintetico extends Relatorio { sql.append(" ca.indreimpresion = 0 "); sql.append(" and ca.feccorte >= :DATA_INICIAL "); sql.append(" and ca.feccorte <= :DATA_FINAL "); - if(parametros.get("EMPRESA_ID") != null){ + if (parametros.get("EMPRESA_ID") != null) { sql.append(" and m.EMPRESA_ID = :EMPRESA_ID"); } - + if (parametros.get("NUMPUNTOVENTA") != null) { sql.append(" and ca.puntoventa_id IN (" + parametros.get("NUMPUNTOVENTA").toString() + ")"); } - if(parametros.get("TIPOPUNTOVENTA_ID") != null && !parametros.get("TIPOPUNTOVENTA_ID").toString().equals("-1") ){ + if (parametros.get("TIPOPUNTOVENTA_ID") != null && !parametros.get("TIPOPUNTOVENTA_ID").toString().equals("-1")) { sql.append(" and pv.TIPOPTOVTA_ID = :TIPOPUNTOVENTA_ID "); } sql.append(" group by pv.NUMPUNTOVENTA, us.cveusuario, us.NOMBUSUARIO , tpv.DESCTIPO "); sql.append(" order by pv.NUMPUNTOVENTA, us.NOMBUSUARIO "); - NamedParameterStatement stmt = new NamedParameterStatement(conexao, sql.toString()); - if(parametros.get("EMPRESA_ID") != null){ + if (parametros.get("EMPRESA_ID") != null) { stmt.setInt("EMPRESA_ID", Integer.valueOf(parametros.get("EMPRESA_ID").toString())); } - + stmt.setTimestamp("DATA_INICIAL", new Timestamp(DateUtil.inicioFecha((Date) parametros.get("DATA_INICIAL")).getTime())); stmt.setTimestamp("DATA_FINAL", new Timestamp(DateUtil.fimFecha((Date) parametros.get("DATA_FINAL")).getTime())); - if(parametros.get("TIPOPUNTOVENTA_ID") != null && !parametros.get("TIPOPUNTOVENTA_ID").toString().equals("-1") ){ + if (parametros.get("TIPOPUNTOVENTA_ID") != null && !parametros.get("TIPOPUNTOVENTA_ID").toString().equals("-1")) { stmt.setInt("TIPOPUNTOVENTA_ID", Integer.valueOf(parametros.get("TIPOPUNTOVENTA_ID").toString())); } - + ResultSet rset = stmt.executeQuery(); while (rset.next()) { diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioVendasBilheteiroSintetico.jasper b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioVendasBilheteiroSintetico.jasper index 54f9ece30..899a3f3d5 100644 Binary files a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioVendasBilheteiroSintetico.jasper and b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioVendasBilheteiroSintetico.jasper differ diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioVendasBilheteiroSintetico.jrxml b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioVendasBilheteiroSintetico.jrxml index b4e0d6d37..5e4a3f4e8 100644 --- a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioVendasBilheteiroSintetico.jrxml +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioVendasBilheteiroSintetico.jrxml @@ -2,7 +2,7 @@ - +