diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioVendasComissao.java b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioVendasComissao.java index 68f7a7f13..45b3b2d68 100644 --- a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioVendasComissao.java +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioVendasComissao.java @@ -16,6 +16,7 @@ import com.rjconsultores.ventaboletos.constantes.Constantes; import com.rjconsultores.ventaboletos.relatorios.utilitarios.DataSource; import com.rjconsultores.ventaboletos.relatorios.utilitarios.Relatorio; import com.rjconsultores.ventaboletos.relatorios.utilitarios.RelatorioVendasComissaoBean; +import com.rjconsultores.ventaboletos.relatorios.utilitarios.RelatorioVendasComissaoCancelamentoBean; import com.rjconsultores.ventaboletos.web.utilerias.NamedParameterStatement; import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource; @@ -25,6 +26,7 @@ public class RelatorioVendasComissao extends Relatorio { private static Logger log = Logger.getLogger(RelatorioVendasComissao.class); private List lsDadosRelatorio; + private List lsDadosRelatorioCancelamento; private Timestamp fecInicio; private Timestamp fecFinal; @@ -49,7 +51,13 @@ public class RelatorioVendasComissao extends Relatorio { Connection conexao = this.relatorio.getConexao(); processarVendasComissao(conexao); - setLsDadosRelatorio(lsDadosRelatorio); + + if (apenasCancelados) { + setCollectionDataSource(new JRBeanCollectionDataSource(lsDadosRelatorioCancelamento)); + } else { + setCollectionDataSource(new JRBeanCollectionDataSource(lsDadosRelatorio)); + } + } }); @@ -60,14 +68,15 @@ public class RelatorioVendasComissao extends Relatorio { NamedParameterStatement stmt = null; try { - if(lsDadosRelatorio == null) { - lsDadosRelatorio = new ArrayList(); - } /* Processando vendas normais */ stmt = carregarNamedParameterStatement(conexao); rset = stmt.executeQuery(); - processarResultado(rset); + if (apenasCancelados) { + processarResultadoCancelamento(rset); + } else { + processarResultado(rset); + } fecharConexaoBanco(stmt, rset); } catch (Exception e) { @@ -90,6 +99,9 @@ public class RelatorioVendasComissao extends Relatorio { } private void processarResultado(ResultSet rset) throws SQLException { + if(lsDadosRelatorio == null) { + lsDadosRelatorio = new ArrayList(); + } while (rset.next()) { RelatorioVendasComissaoBean relatorioVendaComissao = new RelatorioVendasComissaoBean(); relatorioVendaComissao.setNumPuntoVenta(rset.getString("NUMPUNTOVENTA")); @@ -127,6 +139,23 @@ public class RelatorioVendasComissao extends Relatorio { } + private void processarResultadoCancelamento(ResultSet rset) throws SQLException { + if(lsDadosRelatorioCancelamento == null) { + lsDadosRelatorioCancelamento = new ArrayList(); + } + while (rset.next()) { + RelatorioVendasComissaoCancelamentoBean relatorioVendaComissao = new RelatorioVendasComissaoCancelamentoBean(); + relatorioVendaComissao.setNumFolioSistema(rset.getString("NUMFOLIOSISTEMA")); + relatorioVendaComissao.setCorridaId(rset.getInt("CORRIDA_ID")); + relatorioVendaComissao.setFecHorViaje(rset.getDate("FECHORVIAJE")); + relatorioVendaComissao.setNumAsiento(rset.getString("NUMASIENTO")); + relatorioVendaComissao.setPrecioTotalPagado(rset.getBigDecimal("TOTAL")); + relatorioVendaComissao.setFecHorVenta(rset.getDate("FECHORVENTA")); + lsDadosRelatorioCancelamento.add(relatorioVendaComissao); + } + + } + private boolean isCancelamento(String indstatusboleto) { return "C".equals(indstatusboleto); } @@ -163,7 +192,7 @@ public class RelatorioVendasComissao extends Relatorio { } private NamedParameterStatement carregarNamedParameterStatement(Connection conexao) throws SQLException { - String sql = getSql(); + String sql = apenasCancelados ? getSqlCancelados() : getSql(); log.info(sql); NamedParameterStatement stmt = new NamedParameterStatement(conexao, sql); @@ -211,6 +240,25 @@ public class RelatorioVendasComissao extends Relatorio { return sQuery.toString(); } + protected String getSqlCancelados() { + + StringBuilder sQuery = new StringBuilder(); + + sQuery.append("SELECT C.NUMFOLIOSISTEMA, C.CORRIDA_ID, C.FECHORVIAJE, C.NUMASIENTO, C.PRECIOPAGADO, C.FECHORVENTA, ") + .append("(COALESCE (C.PRECIOPAGADO,0) + COALESCE (C.IMPORTETAXAEMBARQUE,0) + COALESCE (C.IMPORTESEGURO,0) + COALESCE (C.IMPORTEPEDAGIO,0) + COALESCE (C.IMPORTEOUTROS,0)) AS TOTAL ") + .append("FROM CAJA C ") + .append("JOIN MARCA M ON M.MARCA_ID = C.MARCA_ID ") + .append("WHERE C.INDCANCELACION = 1 AND C.INDSTATUSBOLETO = 'C' "); + + sQuery.append("AND C.FECHORVENTA BETWEEN :fecInicio AND :fecFinal "); + if(parametros.get("EMPRESA_ID")!= null) { + sQuery.append("AND M.EMPRESA_ID =:EMPRESA_ID "); + } + + return sQuery.toString(); + + } + @Override protected void processaParametros() throws Exception { } @@ -218,10 +266,13 @@ public class RelatorioVendasComissao extends Relatorio { public List getLsDadosRelatorio() { return lsDadosRelatorio; } - - public void setLsDadosRelatorio(List lsDadosRelatorio) { - this.setCollectionDataSource(new JRBeanCollectionDataSource(lsDadosRelatorio)); - this.lsDadosRelatorio = lsDadosRelatorio; + + @Override + public String getNome() { + if (apenasCancelados) { + return "RelatorioVendasComissaoCancelamento"; + } + return super.getNome(); } } diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioVendasComissaoCancelamento_es.properties b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioVendasComissaoCancelamento_es.properties new file mode 100644 index 000000000..ba65ae0a3 --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioVendasComissaoCancelamento_es.properties @@ -0,0 +1,21 @@ +#geral +msg.noData=Não foi possivel obter dados com os parâmetros informados. + +#Labels cabeçalho +cabecalho.nome=Relatório Vendas para Comissão +cabecalho.relatorio=Relatório: +cabecalho.periodo=Período: +cabecalho.periodoA=à +cabecalho.dataHora=Data/Hora: +cabecalho.impressorPor=Impressor por: +cabecalho.pagina=Página +cabecalho.de=de +cabecalho.filtros=Filtros: +cabecalho.usuario=Usuário: +label.total=Total +label.numFolioSistema=Número de Entradas +label.corridaId=Número de Servicio +label.fecHorViaje=Data Servicio +label.numAsiento=Número de Asiento +label.precioTotalPagado=Valor de Entradas +label.fecHorVenta=Fecha de Regreso \ No newline at end of file diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioVendasComissaoCancelamento_pt_BR.properties b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioVendasComissaoCancelamento_pt_BR.properties new file mode 100644 index 000000000..acc9e4a3f --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioVendasComissaoCancelamento_pt_BR.properties @@ -0,0 +1,21 @@ +#geral +msg.noData=Não foi possivel obter dados com os parâmetros informados. + +#Labels cabeçalho +cabecalho.nome=Relatório Vendas para Comissão +cabecalho.relatorio=Relatório: +cabecalho.periodo=Período: +cabecalho.periodoA=à +cabecalho.dataHora=Data/Hora: +cabecalho.impressorPor=Impressor por: +cabecalho.pagina=Página +cabecalho.de=de +cabecalho.filtros=Filtros: +cabecalho.usuario=Usuário: +label.total=Total +label.numFolioSistema=Número do Bilhete +label.corridaId=Número do Serviço +label.fecHorViaje=Data do Serviço +label.numAsiento=Poltrona +label.precioTotalPagado=Valor do Bilhete +label.fecHorVenta=Data da Devolução \ No newline at end of file diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioVendasComissaoCancelamento.jasper b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioVendasComissaoCancelamento.jasper new file mode 100644 index 000000000..e9a4d071d Binary files /dev/null and b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioVendasComissaoCancelamento.jasper differ diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioVendasComissaoCancelamento.jrxml b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioVendasComissaoCancelamento.jrxml new file mode 100644 index 000000000..7c6e8b145 --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioVendasComissaoCancelamento.jrxml @@ -0,0 +1,172 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + <band height="81" splitType="Stretch"> + <textField> + <reportElement x="0" y="0" width="620" height="20" uuid="43b2c28d-4760-4890-b00d-25e931e79c74"/> + <textElement markup="none"> + <font size="14" isBold="true"/> + </textElement> + <textFieldExpression><![CDATA[$R{cabecalho.nome}]]></textFieldExpression> + </textField> + <textField pattern="dd/MM/yyyy HH:mm"> + <reportElement x="638" y="0" width="164" height="20" uuid="4d1bcd65-c9a6-44b4-8dca-cc3c4c20c9a5"/> + <textElement textAlignment="Right"> + <font isBold="true"/> + </textElement> + <textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression> + </textField> + <textField> + <reportElement x="0" y="20" width="620" height="20" uuid="fd05bd35-30d9-4baf-aa56-f8e5d3c3268b"/> + <textElement> + <font isBold="true"/> + </textElement> + <textFieldExpression><![CDATA[$R{cabecalho.periodo} + " " + $P{fecInicio} + " " + $R{cabecalho.periodoA} + " " + $P{fecFinal}]]></textFieldExpression> + </textField> + <textField> + <reportElement x="53" y="41" width="139" height="20" uuid="8fa1c53b-1da7-4d4d-a75c-ab1543acae2a"/> + <textFieldExpression><![CDATA[$P{empresa}]]></textFieldExpression> + </textField> + <staticText> + <reportElement x="0" y="41" width="53" height="20" uuid="a91f6081-4740-4e36-8965-41b6cde4cc20"/> + <text><![CDATA[Empresa:]]></text> + </staticText> + <textField> + <reportElement x="0" y="61" width="139" height="20" uuid="f1811f21-420c-4faf-87d2-2d46e1b74118"/> + <textElement> + <font isBold="true" pdfFontName="Helvetica-Bold"/> + </textElement> + <textFieldExpression><![CDATA[$P{apenasCancelados} ? "Apenas cancelamentos" : ""]]></textFieldExpression> + </textField> + </band> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/utilitarios/RelatorioVendasComissaoCancelamentoBean.java b/src/java/com/rjconsultores/ventaboletos/relatorios/utilitarios/RelatorioVendasComissaoCancelamentoBean.java new file mode 100644 index 000000000..da05b353c --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/utilitarios/RelatorioVendasComissaoCancelamentoBean.java @@ -0,0 +1,68 @@ +package com.rjconsultores.ventaboletos.relatorios.utilitarios; + +import java.math.BigDecimal; +import java.util.Date; + +public class RelatorioVendasComissaoCancelamentoBean { + + private String numFolioSistema; + + private Integer corridaId; + + private Date fecHorViaje; + + private String numAsiento; + + private BigDecimal precioTotalPagado; + + private Date fecHorVenta; + + public String getNumFolioSistema() { + return numFolioSistema; + } + + public void setNumFolioSistema(String numFolioSistema) { + this.numFolioSistema = numFolioSistema; + } + + public Integer getCorridaId() { + return corridaId; + } + + public void setCorridaId(Integer corridaId) { + this.corridaId = corridaId; + } + + public Date getFecHorViaje() { + return fecHorViaje; + } + + public void setFecHorViaje(Date fecHorViaje) { + this.fecHorViaje = fecHorViaje; + } + + public String getNumAsiento() { + return numAsiento; + } + + public void setNumAsiento(String numAsiento) { + this.numAsiento = numAsiento; + } + + public BigDecimal getPrecioTotalPagado() { + return precioTotalPagado; + } + + public void setPrecioTotalPagado(BigDecimal precioTotalPagado) { + this.precioTotalPagado = precioTotalPagado; + } + + public Date getFecHorVenta() { + return fecHorVenta; + } + + public void setFecHorVenta(Date fecHorVenta) { + this.fecHorVenta = fecHorVenta; + } + +}