diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioFinanceiroSintetico.java b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioFinanceiroSintetico.java new file mode 100644 index 000000000..72b45ee71 --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioFinanceiroSintetico.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.sql.SQLException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Date; +import java.util.List; +import java.util.Map; + +import org.apache.log4j.Logger; + +import com.rjconsultores.ventaboletos.entidad.Empresa; +import com.rjconsultores.ventaboletos.entidad.Estado; +import com.rjconsultores.ventaboletos.entidad.PuntoVenta; +import com.rjconsultores.ventaboletos.entidad.TipoPuntoVenta; +import com.rjconsultores.ventaboletos.relatorios.utilitarios.DataSource; +import com.rjconsultores.ventaboletos.relatorios.utilitarios.Relatorio; +import com.rjconsultores.ventaboletos.utilerias.DateUtil; +import com.rjconsultores.ventaboletos.utilerias.fiscal.vo.FinanceiroSintetico; +import com.rjconsultores.ventaboletos.web.utilerias.NamedParameterStatement; + +import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource; + +public class RelatorioFinanceiroSintetico extends Relatorio { + + private static Logger log = Logger.getLogger(RelatorioFolioRmd.class); + List listdata = null; + + @SuppressWarnings("unchecked") + public RelatorioFinanceiroSintetico(final Map parametros, Connection conexao) throws Exception { + super(parametros, conexao); + + this.setCustomDataSource(new DataSource(this) { + @Override + public void initDados() throws Exception { + try { + Date inicio = (Date) parametros.get("inicio"); + Date fim = (Date) parametros.get("fim"); + Empresa empresa = (Empresa) parametros.get("empresa"); + TipoPuntoVenta tipoPuntoVenta = (TipoPuntoVenta) parametros.get("tipoPuntoVenta"); + + List estados = (List) parametros.get("estados"); + String ufs = null; + for (Estado estado : estados) { + if (ufs == null) + ufs = estado.getEstadoId().toString(); + else + ufs = ufs + "," + estado.getEstadoId().toString(); + } + + List agencias = (List) parametros.get("agencias"); + String pdvs = null; + for (PuntoVenta pv : agencias) { + if (pdvs == null) + pdvs = pv.getPuntoventaId().toString(); + else + pdvs = pdvs + "," + pv.getPuntoventaId().toString(); + } + + NamedParameterStatement stmt = new NamedParameterStatement(getConexao(), getSql(ufs, pdvs, tipoPuntoVenta == null ? -1 : tipoPuntoVenta.getTipoptovtaId().intValue())); + stmt.setInt("EMPRESA_ID", empresa.getEmpresaId()); + stmt.setTimestamp("DATE_INICIO", new java.sql.Timestamp(DateUtil.inicioFecha(inicio).getTime())); + stmt.setTimestamp("DATE_FIM", new java.sql.Timestamp(DateUtil.fimFecha(fim).getTime())); + + listdata = new ArrayList(); + ResultSet rset = stmt.executeQuery(); + while (rset.next()) { + FinanceiroSintetico fs = new FinanceiroSintetico(); + fs.setUf(rset.getString("uf")); + fs.setCodigoAgencia(rset.getString("codigo")); + + fs.setReceitaBPR(getBigDecimal(rset, "receita_bpr")); + fs.setGapVenda(getBigDecimal(rset, "receita_gap")); + fs.setGapImpressa(getBigDecimal(rset, "entrega_gap")); + + BigDecimal totalVendaPassagens = fs.getReceitaBPR().add(fs.getGapVenda()).add(fs.getGapImpressa()); + fs.setTotalVendaPassagens(totalVendaPassagens); + + fs.setReceitaEb(getBigDecimal(rset, "receita_eb")); + fs.setMultaComp(getBigDecimal(rset, "receita_multa")); + fs.setDifTrocaOCD(getBigDecimal(rset, "receita_dif_troca_ocd")); + fs.setDifTarifaMaior(getBigDecimal(rset, "receita_dif_dif_tarifa_maior")); + + BigDecimal totalOutrasReceitas = fs.getReceitaEb().add(fs.getMultaComp()).add(fs.getDifTrocaOCD()).add(fs.getDifTarifaMaior()); + fs.setTotalOutrasReceitas(totalOutrasReceitas); + + fs.setTxEmb(getBigDecimal(rset, "taxaEmbarque")); + fs.setPedagio(getBigDecimal(rset, "pedagio")); + fs.setSegFacult(getBigDecimal(rset, "seguro")); + + BigDecimal totalTerceiros = fs.getTxEmb().add(fs.getPedagio()).add(fs.getSegFacult()); + fs.setTotalTerceiros(totalTerceiros); + + BigDecimal receitaBruta = totalVendaPassagens.add(totalOutrasReceitas).add(totalTerceiros); + fs.setReceitaBruta(receitaBruta); + + fs.setDevolBPR(getBigDecimal(rset, "receita_devol_bpr")); + fs.setDevolGAP(getBigDecimal(rset, "receita_devol_gap")); + + BigDecimal totalDevolucao = fs.getDevolBPR().add(fs.getDevolGAP()); + BigDecimal receitaLiquida = receitaBruta.subtract(totalDevolucao); + fs.setReceitaLiquida(receitaLiquida); + + fs.setDespesas(getBigDecimal(rset, "despesas")); + fs.setPgOCD(getBigDecimal(rset, "receita_ocd_deb")); + fs.setDifTarifaMenor(getBigDecimal(rset, "receita_dif_dif_tarifa_menor")); + fs.setCartaoCredito(getBigDecimal(rset, "cartao_credito")); + fs.setCartaoDebito(getBigDecimal(rset, "cartao_debito")); + fs.setBoletoBancario(getBigDecimal(rset, "boleto_bnc")); + fs.setDeposito(getBigDecimal(rset, "deposito")); + + BigDecimal totalDetalhamento = fs.getDespesas().add(fs.getPgOCD()).add(fs.getDifTarifaMenor()) + .add(fs.getCartaoCredito()).add(fs.getCartaoDebito()).add(fs.getBoletoBancario()) + .add(fs.getDeposito()); + fs.setTotalDetalhamento(totalDetalhamento); + + BigDecimal saldo = totalDetalhamento.subtract(receitaLiquida); + fs.setSaldo(saldo); + + listdata.add(fs); + } + + if (!getConexao().isClosed()) + getConexao().close(); + + Collections.sort(listdata); + + } catch (SQLException e) { + log.error("", e); + } + } + + }); + + this.setCollectionDataSource(new JRBeanCollectionDataSource(listdata)); + } + + static public BigDecimal getBigDecimal(ResultSet rs, String strColName) throws SQLException { + BigDecimal nValue = rs.getBigDecimal(strColName); + return rs.wasNull() ? BigDecimal.ZERO : nValue; + } + + @Override + protected void processaParametros() throws Exception { + } + + private String getSql(String ufs, String pdvs, Integer tipoptovtaId) { + + StringBuilder sql = new StringBuilder(); + sql.append("select * from "); + sql.append(" "); + sql.append("(select "); + sql.append(" cd.estadoOrigem as uf, "); + sql.append(" cd.estadoId, "); + sql.append(" cd.codigo, "); + sql.append(" cd.puntoventaId, "); + sql.append(" cd.empresaId, "); + sql.append(" sum(case when cd.venda = 1 then cd.taxaEmbarque else 0 end) as taxaEmbarque, "); + sql.append(" sum(case when cd.venda = 1 then cd.pedagio else 0 end) as pedagio, "); + sql.append(" sum(case when cd.venda = 1 then cd.seguro else 0 end) as seguro, "); + sql.append(" sum(case when (cd.venda = 1 and cd.bpr = 1) then cd.tarifa else 0 end) as receita_bpr, "); + sql.append(" sum(case when (cd.venda = 1 and cd.gap = 1) then cd.valorpago else 0 end) as receita_gap, "); + sql.append(" sum(case when (cd.entrega_gap = 1) then cd.valorpago else 0 end) as entrega_gap, "); + sql.append(" sum(case when (cd.indcancelacion = 1 and cd.bpr = 1) then cd.valorpago else 0 end) as receita_devol_bpr, "); + sql.append(" sum(case when (cd.indcancelacion = 1 and cd.gap = 1) then cd.valorpago else 0 end) as receita_devol_gap, "); + sql.append(" sum(case when (cd.venda = 1 and cd.pagamento_credito = 1) then cd.valorpago else 0 end) as cartao_credito, "); + sql.append(" sum(case when (cd.venda = 1 and cd.pagamento_debito = 1) then cd.valorpago else 0 end) as cartao_debito, "); + sql.append(" sum(case when (cd.indcancelacion = 1 and cd.ocd_deb = 1) then cd.valorpago else 0 end) as receita_ocd_deb, "); + sql.append(" sum(case when (cd.ocd_cred = 1) then cd.valorpago else 0 end) as receita_ocd_cred "); + sql.append(" "); + sql.append("from ( "); + sql.append(" select "); + sql.append(" c.caja_id as cajaid, "); + sql.append(" e.empresa_id as empresaId, "); + sql.append(" pv.puntoventa_id as puntoventaId, "); + sql.append(" pv.numpuntoventa as codigo, "); + sql.append(" eo.estado_id as estadoId, "); + sql.append(" eo.cveestado as estadoOrigem, "); + sql.append(" c.indstatusboleto, "); + sql.append(" c.indreimpresion, "); + sql.append(" c.indcancelacion, "); + sql.append(" case when c.indstatusboleto = 'V' and c.indcancelacion = 0 and c.indreimpresion = 0 then 1 else 0 end as venda, "); + sql.append(" case when c.tipoventa_id not in (5,12,18,49) then 1 else 0 end as bpr, "); + sql.append(" case when c.tipoventa_id in (5,12,18,49) then 1 else 0 end as gap, "); + sql.append(" case when c.motivocancelacion_id in (35) then 1 else 0 end as ocd_deb, "); + sql.append(" coalesce(cfp.importe, 0) as valorpago, "); + sql.append(" coalesce(c.preciobase, 0) as precobase, "); + sql.append(" coalesce(c.preciopagado, 0) as tarifa, "); + sql.append(" coalesce(c.importetaxaembarque, 0) as taxaEmbarque, "); + sql.append(" coalesce(c.importepedagio, 0) as pedagio, "); + sql.append(" coalesce(c.importeseguro, 0) as seguro, "); + sql.append(" coalesce(c.importeoutros, 0) as outros, "); + sql.append(" cfp.formapago_id, "); + sql.append(" c.motivocancelacion_id as motivocancelacion_id, "); + sql.append(" c.tipoventa_id as tipoventa_id, "); + sql.append(" case when (c.tipoventa_id in (5,12,18,49) and indstatusboleto = 'E') then 1 else 0 end as entrega_gap, "); + sql.append(" case when c.indreimpresion = 1 and indstatusboleto = 'T' then 1 else 0 end as nao_entra_no_caixa, "); + sql.append(" case when cfp.formapago_id = 1 then 1 else 0 end as pagamento_dinheiro, "); + sql.append(" case when cfp.formapago_id in (3,26) then 1 else 0 end as pagamento_debito, "); + sql.append(" case when cfp.formapago_id in (2,25) then 1 else 0 end as pagamento_credito, "); + sql.append(" case when cfp.formapago_id not in (1,2,3,25,26) then 1 else 0 end as pagamento_outro, "); + sql.append(" case when c.motivocancelacion_id in (99) then 1 else 0 end as ocd_cred "); + sql.append(" from caja c "); + sql.append(" inner join caja_formapago cfp on cfp.caja_id = c.caja_id "); + sql.append(" inner join punto_venta pv on pv.puntoventa_id = c.puntoventa_id "); + sql.append(" inner join forma_pago fp on cfp.formapago_id = fp.formapago_id "); + sql.append(" inner join marca m on c.marca_id = m.marca_id "); + sql.append(" inner join empresa e on e.empresa_id = m.empresa_id "); + sql.append(" inner join parada po on po.parada_id = c.origen_id "); + sql.append(" inner join ciudad co on co.ciudad_id = po.ciudad_id "); + sql.append(" inner join estado eo on eo.estado_id = co.estado_id "); + sql.append(" where c.fechorventa between :DATE_INICIO and :DATE_FIM "); + sql.append(" and e.empresa_id = :EMPRESA_ID "); + sql.append(ufs == null ? "" : "and eo.estado_id in ( " + ufs + " ) "); + sql.append(pdvs == null ? "" : "and pv.puntoventa_id in ( " + pdvs + " ) "); + sql.append(tipoptovtaId == -1 ? "" : "and pv.tipoptovta_id = " + tipoptovtaId); + // sql.append(" order by e.empresa_id, eo.estado_id) cd "); + sql.append(" ) cd "); + sql.append(" where cd.nao_entra_no_caixa = 0 "); + sql.append(" group by cd.estadoOrigem, cd.estadoId, cd.codigo, cd.puntoventaId, cd.empresaId ) agrc "); + sql.append("left join ( "); + sql.append(" select ed.puntoventaId, ed.estadoId, ed.empresaId, "); + sql.append(" sum(case when tipoeventoextra_id = 82 and indtipo = 1 then impingreso else 0 end) as receita_eb, "); + sql.append(" sum(case when tipoeventoextra_id in (102,42) and indtipo = 1 then impingreso else 0 end) as receita_multa, "); + sql.append(" sum(case when tipoeventoextra_id in (103,99978,99999) and indtipo = 1 then impingreso else 0 end) as receita_dif_troca_ocd, "); + sql.append(" sum(case when tipoeventoextra_id in (43) and indtipo = 1 then impingreso else 0 end) as receita_dif_dif_tarifa_maior, "); + sql.append(" sum(case when tipoeventoextra_id in (44) and indtipo = 0 then impingreso else 0 end) as receita_dif_dif_tarifa_menor, "); + sql.append(" sum(case when tipoeventoextra_id not in (44) and indtipo = 0 then impingreso else 0 end) as despesas "); + sql.append(" from ( "); + sql.append(" select ee.tipoeventoextra_id, ee.impingreso, tee.indtipo, pv.puntoventa_id as puntoventaId, eo.estado_id as estadoId, ee.empresa_id as empresaId "); + sql.append(" from evento_extra ee "); + sql.append(" join tipo_evento_extra tee on ee.tipoeventoextra_id = tee.tipoeventoextra_id "); + sql.append(" join punto_venta pv on pv.puntoventa_id = ee.puntoventa_id "); + sql.append(" join parada po on po.parada_id = pv.parada_id "); + sql.append(" join ciudad co on co.ciudad_id = po.ciudad_id "); + sql.append(" join estado eo on eo.estado_id = co.estado_id "); + sql.append(" where ee.activo = 1 and ee.empresa_id = :EMPRESA_ID "); + sql.append(ufs == null ? "" : "and eo.estado_id in ( " + ufs + " ) "); + sql.append(pdvs == null ? "" : "and pv.puntoventa_id in ( " + pdvs + " ) "); + sql.append(tipoptovtaId == -1 ? "" : "and pv.tipoptovta_id = " + tipoptovtaId); + sql.append(" and ee.fechoringreso between :DATE_INICIO and :DATE_FIM "); + sql.append(" ) ed "); + sql.append(" group by ed.puntoventaId, ed.estadoId, ed.empresaId "); + sql.append(" ) eed on agrc.empresaId = eed.empresaId and agrc.puntoventaId = eed.puntoventaId and agrc.estadoId = eed.estadoId "); + sql.append("left join ( "); + sql.append(" select coalesce(sum(fd.valor), 0) as deposito, pv.puntoventa_id as puntoventaId, fcc.empresa_id as empresaId, eo.estado_id as estadoId "); + sql.append(" from fechamento_cntcorrente fcc "); + sql.append(" join fechamento_cct_deposito fcd on fcd.fechamentocntcorrente_id = fcc.fechamentocntcorrente_id "); + sql.append(" join fechamento_deposito fd on fd.fechamentocntcorrente_id = fcd.fechamentocntcorrente_id "); + sql.append(" join punto_venta pv on pv.puntoventa_id = fcc.puntoventa_id "); + sql.append(" join parada po on po.parada_id = pv.parada_id "); + sql.append(" join ciudad co on co.ciudad_id = po.ciudad_id "); + sql.append(" join estado eo on eo.estado_id = co.estado_id "); + sql.append(" where fcc.activo = 1 and fcc.empresa_id = :EMPRESA_ID "); + sql.append(ufs == null ? "" : "and eo.estado_id in ( " + ufs + " ) "); + sql.append(pdvs == null ? "" : "and pv.puntoventa_id in ( " + pdvs + " ) "); + sql.append(tipoptovtaId == -1 ? "" : "and pv.tipoptovta_id = " + tipoptovtaId); + sql.append(" and fd.feccreacion between :DATE_INICIO and :DATE_FIM "); + sql.append(" group by pv.puntoventa_id, fcc.empresa_id, eo.estado_id "); + sql.append(" ) depd on agrc.empresaId = depd.empresaId and agrc.puntoventaId = depd.puntoventaId and agrc.estadoId = depd.estadoId "); + sql.append("left join ( "); + sql.append(" select coalesce(sum(fb.valordocumento), 0) as boleto_bnc , pv.puntoventa_id as puntoventaId, fcc.empresa_id as empresaId, eo.estado_id as estadoId "); + sql.append(" from fechamento_cntcorrente fcc "); + sql.append(" join fechamento_boleto fb on fb.fechamentocntcorrente_id = fcc.fechamentocntcorrente_id "); + sql.append(" join punto_venta pv on pv.puntoventa_id = fcc.puntoventa_id "); + sql.append(" join parada po on po.parada_id = pv.parada_id "); + sql.append(" join ciudad co on co.ciudad_id = po.ciudad_id "); + sql.append(" join estado eo on eo.estado_id = co.estado_id "); + sql.append(" where fcc.activo = 1 and fcc.empresa_id = :EMPRESA_ID "); + sql.append(ufs == null ? "" : "and eo.estado_id in ( " + ufs + " ) "); + sql.append(pdvs == null ? "" : "and pv.puntoventa_id in ( " + pdvs + " ) "); + sql.append(tipoptovtaId == -1 ? "" : "and pv.tipoptovta_id = " + tipoptovtaId); + sql.append(" and fb.fecmodif between :DATE_INICIO and :DATE_FIM "); + sql.append(" group by pv.puntoventa_id, fcc.empresa_id, eo.estado_id "); + sql.append(" ) bold on agrc.empresaId = bold.empresaId and agrc.puntoventaId = bold.puntoventaId and agrc.estadoId = bold.estadoId "); + + return sql.toString(); + } + +} diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioFinanceiroSintetico_es.properties b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioFinanceiroSintetico_es.properties new file mode 100644 index 000000000..57daa3700 --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioFinanceiroSintetico_es.properties @@ -0,0 +1,2 @@ +#geral +msg.noData=Não foi possivel obter dados com os parâmetros informados. \ No newline at end of file diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioFinanceiroSintetico_pt_BR.properties b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioFinanceiroSintetico_pt_BR.properties new file mode 100644 index 000000000..57daa3700 --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioFinanceiroSintetico_pt_BR.properties @@ -0,0 +1,2 @@ +#geral +msg.noData=Não foi possivel obter dados com os parâmetros informados. \ No newline at end of file diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioFinanceiroSintetico.jasper b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioFinanceiroSintetico.jasper new file mode 100644 index 000000000..d9dd967f8 Binary files /dev/null and b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioFinanceiroSintetico.jasper differ diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioFinanceiroSintetico.jrxml b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioFinanceiroSintetico.jrxml new file mode 100644 index 000000000..aee9aa7df --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioFinanceiroSintetico.jrxml @@ -0,0 +1,834 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/impressaofiscal/BusquedaRelatorioFinanceiroController.java b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/impressaofiscal/BusquedaRelatorioFinanceiroController.java new file mode 100644 index 000000000..a1680563a --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/impressaofiscal/BusquedaRelatorioFinanceiroController.java @@ -0,0 +1,203 @@ +package com.rjconsultores.ventaboletos.web.gui.controladores.impressaofiscal; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.sql.DataSource; + +import org.apache.log4j.Logger; +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.Combobox; +import org.zkoss.zul.Datebox; +import org.zkoss.zul.Paging; +import org.zkoss.zul.Textbox; + +import com.rjconsultores.ventaboletos.entidad.Empresa; +import com.rjconsultores.ventaboletos.entidad.Estado; +import com.rjconsultores.ventaboletos.entidad.PuntoVenta; +import com.rjconsultores.ventaboletos.entidad.TipoPuntoVenta; +import com.rjconsultores.ventaboletos.relatorios.impl.RelatorioFinanceiroSintetico; +import com.rjconsultores.ventaboletos.relatorios.utilitarios.Relatorio; +import com.rjconsultores.ventaboletos.service.EmpresaService; +import com.rjconsultores.ventaboletos.service.EstadoService; +import com.rjconsultores.ventaboletos.service.TipoPuntoVentaService; +import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; +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.paginacion.HibernateSearchObject; +import com.rjconsultores.ventaboletos.web.utilerias.paginacion.PagedListWrapper; +import com.rjconsultores.ventaboletos.web.utilerias.render.RenderEstadoUf; +import com.rjconsultores.ventaboletos.web.utilerias.render.RenderPuntoVentaSimple; +import com.trg.search.Filter; + +@Controller("busquedaRelatorioFinanceiroController") +@Scope("prototype") +public class BusquedaRelatorioFinanceiroController extends MyGenericForwardComposer { + private static final long serialVersionUID = 1L; + + private static Logger log = Logger.getLogger(BusquedaRelatorioFinanceiroController.class); + + @Autowired + private DataSource dataSourceRead; + + @Autowired + private EmpresaService empresaService; + + @Autowired + private EstadoService estadoService; + + @Autowired + private TipoPuntoVentaService tipoPuntoVentaService; + + @Autowired + private transient PagedListWrapper plwPuntoVenta; + + private List lsEmpresa; + private List lsEstado; + + private Datebox datInicial; + private Datebox datFinal; + + private MyComboboxEstandar cmbEmpresa; + + private List lsTipoPuntoVenta; + private Combobox cmbTipoPuntoVenta; + + private MyListbox estadoList; + private MyListbox puntoVentaList; + + private Textbox txtPalavraPesquisa; + private MyListbox puntoVentaSelList; + private Paging pagingPuntoVenta; + + @Override + public void doAfterCompose(Component comp) throws Exception { + lsEmpresa = empresaService.obtenerTodos(); + lsEstado = estadoService.obtenerTodos(); + lsTipoPuntoVenta = tipoPuntoVentaService.obtenerTodos(); + + super.doAfterCompose(comp); + + estadoList.setItemRenderer(new RenderEstadoUf()); + estadoList.setData(lsEstado); + puntoVentaList.setItemRenderer(new RenderPuntoVentaSimple()); + puntoVentaSelList.setItemRenderer(new RenderPuntoVentaSimple()); + } + + @SuppressWarnings({ "rawtypes", "unchecked" }) + private void executar() throws InterruptedException { + + try { + Empresa empresa = cmbEmpresa == null ? null : (cmbEmpresa.getSelectedItem() == null ? null : (Empresa) cmbEmpresa.getSelectedItem().getValue()); + TipoPuntoVenta tipoPuntoVenta = cmbTipoPuntoVenta == null ? null : (cmbTipoPuntoVenta.getSelectedItem() == null ? null : (TipoPuntoVenta) cmbTipoPuntoVenta.getSelectedItem().getValue()); + List agencias = new ArrayList(Arrays.asList(puntoVentaSelList.getData())); + + List estados = new ArrayList(); + for (Object ob : estadoList.getSelectedItemsByIndex()) { + estados.add((Estado) ob); + } + + Map parametros = new HashMap(); + parametros.put("empresa", empresa); + parametros.put("nombempresa", empresa.getNombempresa()); + parametros.put("tipoPuntoVenta", tipoPuntoVenta); + parametros.put("agencias", agencias); + parametros.put("estados", estados); + parametros.put("inicio", datInicial.getValue()); + parametros.put("fim", datFinal.getValue()); + parametros.put("usuario", UsuarioLogado.getUsuarioLogado().getClaveUsuario()); + + Relatorio relatorio = new RelatorioFinanceiroSintetico(parametros, dataSourceRead.getConnection()); + + Map args = new HashMap(); + args.put("relatorio", relatorio); + + openWindow("/component/reportView.zul", + Labels.getLabel("indexController.mnRelatorioRDI.label"), args, MODAL); + + } catch (Exception e) { + log.error("", e); + Messagebox.show(e.getMessage(), + Labels.getLabel("indexController.mnImpressaoRMD.label"), + Messagebox.OK, Messagebox.INFORMATION); + } + } + + private void executarPesquisa() { + HibernateSearchObject puntoVentaBusqueda = new HibernateSearchObject(PuntoVenta.class, + pagingPuntoVenta.getPageSize()); + + puntoVentaBusqueda.addFilterOr(Filter.like("nombpuntoventa", "%" + txtPalavraPesquisa.getText().trim().toUpperCase().concat("%")), Filter.like("numPuntoVenta", "%" + txtPalavraPesquisa.getText().trim().toUpperCase().concat("%"))); + + puntoVentaBusqueda.addSortAsc("nombpuntoventa"); + + puntoVentaBusqueda.addFilterEqual("activo", Boolean.TRUE); + + plwPuntoVenta.init(puntoVentaBusqueda, puntoVentaList, pagingPuntoVenta); + + if (puntoVentaList.getData().length == 0) { + try { + Messagebox.show(Labels.getLabel("MSG.ningunRegistro"), + Labels.getLabel("relatorioReceitaDiariaAgenciaController.window.title"), + Messagebox.OK, Messagebox.INFORMATION); + } catch (InterruptedException ex) { + } + } + } + + public void onClick$btnLimparPtv(Event ev) { + limparPesquisaAgencia(); + } + + private void limparPesquisaAgencia() { + puntoVentaSelList.setData(new ArrayList()); + } + + public void onClick$btnPesquisaPtv(Event ev) { + executarPesquisa(); + } + + public void onDoubleClick$puntoVentaList(Event ev) { + PuntoVenta puntoVentaSel = (PuntoVenta) puntoVentaList.getSelected(); + puntoVentaSelList.addItemNovo(puntoVentaSel); + } + + public void onDoubleClick$puntoVentaSelList(Event ev) { + PuntoVenta puntoVentaSel = (PuntoVenta) puntoVentaSelList.getSelected(); + puntoVentaSelList.removeItem(puntoVentaSel); + } + + public void onClick$btnSintetico(Event ev) throws InterruptedException { + executar(); + } + +// public void onClick$btnAnalitico(Event ev) throws InterruptedException { +// executar(); +// } + + public List getLsEmpresa() { + return lsEmpresa; + } + + public List getLsEstado() { + return lsEstado; + } + + public List getLsTipoPuntoVenta() { + return lsTipoPuntoVenta; + } + + public MyListbox getPuntoVentaSelList() { + return puntoVentaSelList; + } +} diff --git a/src/java/com/rjconsultores/ventaboletos/web/utilerias/menu/item/relatorios/impressaofiscal/ItemMenuRelatorioFinanceiro.java b/src/java/com/rjconsultores/ventaboletos/web/utilerias/menu/item/relatorios/impressaofiscal/ItemMenuRelatorioFinanceiro.java new file mode 100644 index 000000000..9375815a9 --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/web/utilerias/menu/item/relatorios/impressaofiscal/ItemMenuRelatorioFinanceiro.java @@ -0,0 +1,24 @@ +package com.rjconsultores.ventaboletos.web.utilerias.menu.item.relatorios.impressaofiscal; + +import org.zkoss.util.resource.Labels; + +import com.rjconsultores.ventaboletos.web.utilerias.PantallaUtileria; +import com.rjconsultores.ventaboletos.web.utilerias.menu.DefaultItemMenuSistema; + +public class ItemMenuRelatorioFinanceiro extends DefaultItemMenuSistema { + + public ItemMenuRelatorioFinanceiro() { + super("indexController.mnRelatoriosFinanceiros.label"); + } + + @Override + public String getClaveMenu() { + return "COM.RJCONSULTORES.ADMINISTRACION.GUI.RELATORIOS.RELATORIOSFINANCEIROS"; + } + + @Override + public void ejecutar() { + PantallaUtileria.openWindow("/gui/impressaofiscal/busquedaRelatorioFinanceiro.zul", + Labels.getLabel("indexController.mnRelatoriosFinanceiros.label"), getArgs(), desktop); + } +} \ No newline at end of file diff --git a/web/WEB-INF/i3-label_es_MX.label b/web/WEB-INF/i3-label_es_MX.label index 9e18a2289..96c2cff9e 100644 --- a/web/WEB-INF/i3-label_es_MX.label +++ b/web/WEB-INF/i3-label_es_MX.label @@ -310,6 +310,11 @@ indexController.mnSubMenuExportacaoFiscal.label=Exportación Fiscal indexController.mniExportacaoFiscalECF.label=ECF indexController.mniExportacaoFiscalRMD.label=RMD +indexController.mnImpressaoRMD.label=Impressão RMD +indexController.mnRelatorioRDI.label=Relatório RDI + +indexController.mnRelatoriosFinanceiros.label=Relatórios Financeiros + indexController.mniSubMenuClientePacote.label=Paquete indexController.mniManutencaoPacote.label=Mantenimiento Paquete @@ -6504,7 +6509,21 @@ busquedaImportacionFiscalController.lbGerarArquivo.value = Gerar Archivo busquedaImportacionFiscalController.lbArquivoTxt.value = Importación Texto busquedaImportacionFiscalController.lbArquivoXls.value = Consolidado Excel busquedaImportacionFiscalController.lbCompetencia.label = Competencia -busquedaImportacionFiscalController.btnExe.label = Ejecutar Importación +busquedaImportacionFiscalController.btnExe.label = Ejecutar Importación + +busquedaRelatorioFinanceiroController.lbDataIni.value = Data Inicio +busquedaRelatorioFinanceiroController.lbDataFin.value = Data Final +busquedaRelatorioFinanceiroController.lbEmpresa.value = Empresa +busquedaRelatorioFinanceiroController.estado.label = Estado +busquedaRelatorioFinanceiroController.lbTpoPtoVta.value = Canal de Venda +busquedaRelatorioFinanceiroController.btnSintetico.label = Relatório Sintético +busquedaRelatorioFinanceiroController.btnAnalitico.label = Relatório Analítico +busquedaRelatorioFinanceiroController.lbPuntoVenta.value = Agência +busquedaRelatorioFinanceiroController.puntoVentaSelList.codigo = Código +busquedaRelatorioFinanceiroController.puntoVentaSelList.nome = Nome +busquedaRelatorioFinanceiroController.btnPesquisa.label = Pesquisar +busquedaRelatorioFinanceiroController.btnLimpar.label = Limpar +busquedaRelatorioFinanceiroController.lbPuntoVentaSel.value = Agências Selecionadas #busquedaImportacionFiscalController.btnExe.label = Importación Fiscal ECF #busquedaImportacionFiscalController.btnExeManual.label = Importación Fiscal Manual diff --git a/web/WEB-INF/i3-label_pt_BR.label b/web/WEB-INF/i3-label_pt_BR.label index 01a59bc1d..a39d04f29 100644 --- a/web/WEB-INF/i3-label_pt_BR.label +++ b/web/WEB-INF/i3-label_pt_BR.label @@ -330,6 +330,8 @@ indexController.mniExportacaoFiscalRMD.label=RMD indexController.mnImpressaoRMD.label=Impressão RMD indexController.mnRelatorioRDI.label=Relatório RDI +indexController.mnRelatoriosFinanceiros.label=Relatórios Financeiros + indexController.mniSubMenuClientePacote.label=Pacote indexController.mniManutencaoPacote.label=Manutenção Pacote @@ -6757,6 +6759,20 @@ busquedaImportacionFiscalController.lbArquivoXls.value = Consolidado Excel busquedaImportacionFiscalController.lbCompetencia.label = Competência busquedaImportacionFiscalController.btnExe.label = Executar Importação +busquedaRelatorioFinanceiroController.lbDataIni.value = Data Inicio +busquedaRelatorioFinanceiroController.lbDataFin.value = Data Final +busquedaRelatorioFinanceiroController.lbEmpresa.value = Empresa +busquedaRelatorioFinanceiroController.estado.label = Estado +busquedaRelatorioFinanceiroController.lbTpoPtoVta.value = Canal de Venda +busquedaRelatorioFinanceiroController.btnSintetico.label = Relatório Sintético +busquedaRelatorioFinanceiroController.btnAnalitico.label = Relatório Analítico +busquedaRelatorioFinanceiroController.lbPuntoVenta.value = Agência +busquedaRelatorioFinanceiroController.puntoVentaSelList.codigo = Código +busquedaRelatorioFinanceiroController.puntoVentaSelList.nome = Nome +busquedaRelatorioFinanceiroController.btnPesquisa.label = Pesquisar +busquedaRelatorioFinanceiroController.btnLimpar.label = Limpar +busquedaRelatorioFinanceiroController.lbPuntoVentaSel.value = Agências Selecionadas + #busquedaImportacionFiscalController.btnExe.label = Importação Fiscal ECF #busquedaImportacionFiscalController.btnExeManual.label = Importação Fiscal Manual #busquedaImportacionFiscalController.btnExeNaoFiscal.label = Importação Não Fiscal diff --git a/web/gui/impressaofiscal/busquedaRelatorioFinanceiro.zul b/web/gui/impressaofiscal/busquedaRelatorioFinanceiro.zul new file mode 100644 index 000000000..8d04419d6 --- /dev/null +++ b/web/gui/impressaofiscal/busquedaRelatorioFinanceiro.zul @@ -0,0 +1,122 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +