diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioAnaliticoVoucher.java b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioAnaliticoVoucher.java new file mode 100644 index 000000000..2bde21711 --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioAnaliticoVoucher.java @@ -0,0 +1,118 @@ +package com.rjconsultores.ventaboletos.relatorios.impl; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +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.relatorios.utilitarios.DataSource; +import com.rjconsultores.ventaboletos.relatorios.utilitarios.Relatorio; +import com.rjconsultores.ventaboletos.utilerias.DateUtil; +import com.rjconsultores.ventaboletos.vo.impressaofiscal.ItemRelatorioVoucher; + +import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource; + +public class RelatorioAnaliticoVoucher extends Relatorio { + + private static Logger log = Logger.getLogger(RelatorioAnaliticoVoucher.class); + + List listdata = null; + + public RelatorioAnaliticoVoucher(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"); + + listdata = buscarMovimentosAnaliticos(inicio, fim, empresa.getEmpresaId()); + + } catch (SQLException e) { + log.error("", e); + } + } + + }); + + this.setCollectionDataSource(new JRBeanCollectionDataSource(listdata)); + } + + public List buscarMovimentosAnaliticos(Date inicio, Date fim, Integer empresaId) throws SQLException { + + inicio = DateUtil.inicioFecha(inicio); + fim = DateUtil.fimFecha(fim); + + StringBuilder sql = new StringBuilder(); + sql.append("select "); + sql.append(" TO_CHAR(b.fechorventa, 'dd-MM-yyyy') as dataVendaVoucher, "); + sql.append(" TO_CHAR(impres.fechorventa, 'dd-MM-yyyy') as dataEmissao, "); + sql.append(" e.nombempresa as empresa, "); + sql.append(" fr4.coo as numDocFiscal, "); + sql.append(" coalesce(b.numfoliosistema, impres.numfoliosistema) as bilhete, "); + sql.append(" b.boleto_id as boletoVoucher, "); + sql.append(" impres.boleto_id as boletoImpresso, "); + sql.append(" tv.desctipoventa as tipoVenda, "); + sql.append(" case when b.motivocancelacion_id in (31, 32) then b.preciopagado * -1 else b.preciopagado end as tarifa, "); + sql.append(" case when b.motivocancelacion_id in (31, 32) then b.importepedagio * -1 else b.importepedagio end as pedagio, "); + sql.append(" case when b.motivocancelacion_id in (31, 32) then b.importetaxaembarque * -1 else b.importetaxaembarque end as embarque, "); + sql.append(" case when mc.descmotivo is null then 'VOUCHER' else mc.descmotivo end as status "); + sql.append(" from boleto b "); + sql.append(" join empresa e on b.marca_id = e.empresa_id "); + sql.append(" left join boleto impres on b.boleto_id = impres.boletooriginal_id "); + sql.append(" left join fiscal_r4 fr4 on impres.boleto_id = fr4.boleto_id "); + sql.append(" left join tipo_venta tv on tv.tipoventa_id = coalesce(b.tipoventa_id, impres.tipoventa_id) "); + sql.append(" left join motivo_cancelacion mc on mc.motivocancelacion_id = coalesce(b.motivocancelacion_id, impres.motivocancelacion_id) "); + sql.append(" where b.tipoventa_id in (5,12,18) "); + sql.append(" and b.fechorventa between ? and ? "); + sql.append(" and b.marca_id = ? "); + sql.append(" order by dataVendaVoucher, dataEmissao desc "); + + PreparedStatement stmt = getConexao().prepareStatement(sql.toString()); + stmt.setTimestamp(1, new java.sql.Timestamp(inicio.getTime())); + stmt.setTimestamp(2, new java.sql.Timestamp(fim.getTime())); + stmt.setInt(3, empresaId); + + ResultSet rset = stmt.executeQuery(); + List list = new ArrayList(); + while (rset.next()) { + ItemRelatorioVoucher item = new ItemRelatorioVoucher(); + + item.setDataVendaVoucher(rset.getString("dataVendaVoucher")); + item.setDataEmissao(rset.getString("dataEmissao")); + item.setEmpresa(rset.getString("empresa")); + item.setNumDocFiscal(rset.getString("numDocFiscal")); + item.setBilhete(rset.getString("bilhete")); + item.setBoletoVoucher(rset.getLong("boletoVoucher")); + item.setBoletoImpresso(rset.getLong("boletoImpresso")); + item.setTipoVenda(rset.getString("tipoVenda")); + item.setTarifa(rset.getBigDecimal("tarifa")); + item.setPedagio(rset.getBigDecimal("pedagio")); + item.setEmbarque(rset.getBigDecimal("embarque")); + item.setStatus(rset.getString("status")); + + list.add(item); + } + + if (!getConexao().isClosed()) + getConexao().close(); + + return list; + } + + @Override + protected void processaParametros() throws Exception { + } + +} diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioAnaliticoVoucher_es.properties b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioAnaliticoVoucher_es.properties new file mode 100644 index 000000000..57daa3700 --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioAnaliticoVoucher_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/RelatorioAnaliticoVoucher_pt_BR.properties b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioAnaliticoVoucher_pt_BR.properties new file mode 100644 index 000000000..57daa3700 --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioAnaliticoVoucher_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/RelatorioAnaliticoVoucher.jasper b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioAnaliticoVoucher.jasper new file mode 100644 index 000000000..889547fb4 Binary files /dev/null and b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioAnaliticoVoucher.jasper differ diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioAnaliticoVoucher.jrxml b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioAnaliticoVoucher.jrxml new file mode 100644 index 000000000..8b88d6531 --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioAnaliticoVoucher.jrxml @@ -0,0 +1,227 @@ + + + + + + + + + + + + + + + + + + + + + + <band height="65" splitType="Stretch"> + <textField> + <reportElement x="84" y="40" width="471" height="23" uuid="63ce47a3-7e94-42a2-8325-eceef777fbe2"/> + <textElement verticalAlignment="Middle"/> + <textFieldExpression><![CDATA[$F{empresa}]]></textFieldExpression> + </textField> + <staticText> + <reportElement x="0" y="0" width="276" height="20" uuid="2e2e9caa-4076-4209-bdaf-0017ddf83a56"/> + <textElement verticalAlignment="Middle"> + <font size="14" isBold="true"/> + </textElement> + <text><![CDATA[ANALITICO DE VOUCHERS]]></text> + </staticText> + <textField pattern="dd/MM/yyyy HH:mm"> + <reportElement x="276" y="0" width="279" height="20" uuid="6b4f1375-4f4b-4b80-83b8-7650e62e107e"/> + <textElement textAlignment="Right" verticalAlignment="Middle"> + <font isBold="true"/> + </textElement> + <textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression> + </textField> + <textField> + <reportElement x="0" y="20" width="80" height="20" uuid="3f1d0681-30be-4c3a-ae90-cf34dd4ede3c"/> + <textElement verticalAlignment="Middle"> + <font isBold="true"/> + </textElement> + <textFieldExpression><![CDATA["Período: "]]></textFieldExpression> + </textField> + <staticText> + <reportElement x="0" y="40" width="84" height="23" uuid="cf05ce5a-615b-41ac-b24d-2c45ca1bc60e"/> + <textElement verticalAlignment="Middle"> + <font isBold="true"/> + </textElement> + <text><![CDATA[Empresa:]]></text> + </staticText> + <textField pattern="dd/MM/yyyy"> + <reportElement x="80" y="20" width="78" height="20" uuid="7f5ee01d-f86d-49a4-a2a1-f1c671621ef0"/> + <textElement textAlignment="Left" verticalAlignment="Middle"/> + <textFieldExpression><![CDATA[$P{inicio}]]></textFieldExpression> + </textField> + <textField> + <reportElement x="158" y="20" width="28" height="20" uuid="c1dec10a-743d-4569-916d-f1b65d4475b7"/> + <textElement verticalAlignment="Middle"> + <font isBold="true"/> + </textElement> + <textFieldExpression><![CDATA[" a "]]></textFieldExpression> + </textField> + <textField pattern="dd/MM/yyyy"> + <reportElement x="186" y="20" width="369" height="20" uuid="0b39fe78-5378-404c-b364-8be6ca288e25"/> + <textElement verticalAlignment="Middle"/> + <textFieldExpression><![CDATA[$P{fim}]]></textFieldExpression> + </textField> + <line> + <reportElement x="0" y="63" width="555" height="1" uuid="481b2107-ee62-4815-8a89-8435d34384c8"/> + </line> + </band> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/impressaofiscal/BusquedaImportacionFiscalController.java b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/impressaofiscal/BusquedaImportacionFiscalController.java index 7055fd094..c344059d5 100644 --- a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/impressaofiscal/BusquedaImportacionFiscalController.java +++ b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/impressaofiscal/BusquedaImportacionFiscalController.java @@ -28,6 +28,7 @@ import org.zkoss.zul.Filedownload; import com.rjconsultores.ventaboletos.entidad.Empresa; import com.rjconsultores.ventaboletos.relatorios.impl.RelatorioAnaliticoFinanceiro; +import com.rjconsultores.ventaboletos.relatorios.impl.RelatorioAnaliticoVoucher; import com.rjconsultores.ventaboletos.service.EmpresaService; import com.rjconsultores.ventaboletos.service.FiscalService; import com.rjconsultores.ventaboletos.utilerias.DateUtil; @@ -58,6 +59,7 @@ public class BusquedaImportacionFiscalController extends MyGenericForwardCompose private Button btnExeImportacionManual; private Button btnExeImportacionNaoFiscal; private Button btnExeRelatorioFinanceiro; + private Button btnExeRelatorioVoucher; @Override public void doAfterCompose(Component comp) throws Exception { @@ -111,6 +113,13 @@ public class BusquedaImportacionFiscalController extends MyGenericForwardCompose btnExeRelatorioFinanceiro.setVisible(false); } + boolean isRelatorioVoucher = (Boolean) Executions.getCurrent().getArg().get("RELATORIO_VOUCHER"); + if (isRelatorioVoucher) { + btnExeRelatorioVoucher.setVisible(true); + } else { + btnExeRelatorioVoucher.setVisible(false); + } + } public void onClick$btnExeImportacionManual(Event ev) throws InterruptedException { @@ -240,6 +249,35 @@ public class BusquedaImportacionFiscalController extends MyGenericForwardCompose } } + @SuppressWarnings({ "unchecked", "rawtypes" }) + public void onClick$btnExeRelatorioVoucher(Event ev) throws InterruptedException { + try { + Empresa empresa = null; + Comboitem itemEmpresa = cmbEmpresa.getSelectedItem(); + if (itemEmpresa != null) { + empresa = (Empresa) itemEmpresa.getValue(); + } + + Map parametros = new HashMap(); + parametros.put("inicio", datInicial.getValue()); + parametros.put("fim", datFinal.getValue()); + parametros.put("empresa", empresa); + + RelatorioAnaliticoVoucher relatorio = new RelatorioAnaliticoVoucher(parametros, dataSourceRead.getConnection()); + + Map args = new HashMap(); + args.put("relatorio", relatorio); + + openWindow("/component/reportView.zul", + Labels.getLabel("relatorioAproveitamentoController.window.title"), args, MODAL); + + } catch (SQLException e) { + log.error(e.getMessage(), e); + } catch (Exception e) { + log.error(e.getMessage(), e); + } + } + public List getLsEmpresa() { return lsEmpresa; } diff --git a/src/java/com/rjconsultores/ventaboletos/web/utilerias/menu/item/relatorios/impressaofiscal/TipoImportacaoFiscal.java b/src/java/com/rjconsultores/ventaboletos/web/utilerias/menu/item/relatorios/impressaofiscal/TipoImportacaoFiscal.java index ffaa52918..d626d411d 100644 --- a/src/java/com/rjconsultores/ventaboletos/web/utilerias/menu/item/relatorios/impressaofiscal/TipoImportacaoFiscal.java +++ b/src/java/com/rjconsultores/ventaboletos/web/utilerias/menu/item/relatorios/impressaofiscal/TipoImportacaoFiscal.java @@ -5,12 +5,19 @@ import java.util.HashMap; public class TipoImportacaoFiscal { public enum TipoImportacao { - ECF, ECF_CANCELADOS, MANUAL, REDUCAO_Z, NAO_FISCAL, RELATORIO_FINANCEIRO; + ECF, ECF_CANCELADOS, MANUAL, REDUCAO_Z, NAO_FISCAL, RELATORIO_FINANCEIRO, RELATORIO_VOUCHER; } - public static HashMap selecionaTipoImportacao(TipoImportacao tipo, HashMap args) { + public static HashMap selecionaTipoImportacao(TipoImportacao tipo, HashMap map) { + + map.remove(TipoImportacao.ECF.toString()); + map.remove(TipoImportacao.ECF_CANCELADOS.toString()); + map.remove(TipoImportacao.MANUAL.toString()); + map.remove(TipoImportacao.REDUCAO_Z.toString()); + map.remove(TipoImportacao.NAO_FISCAL.toString()); + map.remove(TipoImportacao.RELATORIO_FINANCEIRO.toString()); + map.remove(TipoImportacao.RELATORIO_VOUCHER.toString()); - HashMap map = args; if (tipo.equals(TipoImportacao.ECF)) { map.put(TipoImportacao.ECF.toString(), Boolean.TRUE); map.put(TipoImportacao.ECF_CANCELADOS.toString(), Boolean.FALSE); @@ -18,6 +25,7 @@ public class TipoImportacaoFiscal { map.put(TipoImportacao.REDUCAO_Z.toString(), Boolean.FALSE); map.put(TipoImportacao.NAO_FISCAL.toString(), Boolean.FALSE); map.put(TipoImportacao.RELATORIO_FINANCEIRO.toString(), Boolean.FALSE); + map.put(TipoImportacao.RELATORIO_VOUCHER.toString(), Boolean.FALSE); } if (tipo.equals(TipoImportacao.ECF_CANCELADOS)) { @@ -27,6 +35,7 @@ public class TipoImportacaoFiscal { map.put(TipoImportacao.REDUCAO_Z.toString(), Boolean.FALSE); map.put(TipoImportacao.NAO_FISCAL.toString(), Boolean.FALSE); map.put(TipoImportacao.RELATORIO_FINANCEIRO.toString(), Boolean.FALSE); + map.put(TipoImportacao.RELATORIO_VOUCHER.toString(), Boolean.FALSE); } if (tipo.equals(TipoImportacao.MANUAL)) { @@ -36,6 +45,7 @@ public class TipoImportacaoFiscal { map.put(TipoImportacao.REDUCAO_Z.toString(), Boolean.FALSE); map.put(TipoImportacao.NAO_FISCAL.toString(), Boolean.FALSE); map.put(TipoImportacao.RELATORIO_FINANCEIRO.toString(), Boolean.FALSE); + map.put(TipoImportacao.RELATORIO_VOUCHER.toString(), Boolean.FALSE); } if (tipo.equals(TipoImportacao.REDUCAO_Z)) { @@ -45,6 +55,7 @@ public class TipoImportacaoFiscal { map.put(TipoImportacao.REDUCAO_Z.toString(), Boolean.TRUE); map.put(TipoImportacao.NAO_FISCAL.toString(), Boolean.FALSE); map.put(TipoImportacao.RELATORIO_FINANCEIRO.toString(), Boolean.FALSE); + map.put(TipoImportacao.RELATORIO_VOUCHER.toString(), Boolean.FALSE); } if (tipo.equals(TipoImportacao.NAO_FISCAL)) { @@ -54,6 +65,7 @@ public class TipoImportacaoFiscal { map.put(TipoImportacao.REDUCAO_Z.toString(), Boolean.FALSE); map.put(TipoImportacao.NAO_FISCAL.toString(), Boolean.TRUE); map.put(TipoImportacao.RELATORIO_FINANCEIRO.toString(), Boolean.FALSE); + map.put(TipoImportacao.RELATORIO_VOUCHER.toString(), Boolean.FALSE); } if (tipo.equals(TipoImportacao.RELATORIO_FINANCEIRO)) { @@ -63,6 +75,17 @@ public class TipoImportacaoFiscal { map.put(TipoImportacao.REDUCAO_Z.toString(), Boolean.FALSE); map.put(TipoImportacao.NAO_FISCAL.toString(), Boolean.FALSE); map.put(TipoImportacao.RELATORIO_FINANCEIRO.toString(), Boolean.TRUE); + map.put(TipoImportacao.RELATORIO_VOUCHER.toString(), Boolean.FALSE); + } + + if (tipo.equals(TipoImportacao.RELATORIO_VOUCHER)) { + map.put(TipoImportacao.ECF.toString(), Boolean.FALSE); + map.put(TipoImportacao.ECF_CANCELADOS.toString(), Boolean.FALSE); + map.put(TipoImportacao.MANUAL.toString(), Boolean.FALSE); + map.put(TipoImportacao.REDUCAO_Z.toString(), Boolean.FALSE); + map.put(TipoImportacao.NAO_FISCAL.toString(), Boolean.FALSE); + map.put(TipoImportacao.RELATORIO_FINANCEIRO.toString(), Boolean.FALSE); + map.put(TipoImportacao.RELATORIO_VOUCHER.toString(), Boolean.TRUE); } return map; diff --git a/src/java/com/rjconsultores/ventaboletos/web/utilerias/menu/item/relatorios/impressaofiscal/relatorios/ItemMenuFiscalRelatorioVoucher.java b/src/java/com/rjconsultores/ventaboletos/web/utilerias/menu/item/relatorios/impressaofiscal/relatorios/ItemMenuFiscalRelatorioVoucher.java new file mode 100644 index 000000000..26ebc926e --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/web/utilerias/menu/item/relatorios/impressaofiscal/relatorios/ItemMenuFiscalRelatorioVoucher.java @@ -0,0 +1,34 @@ +package com.rjconsultores.ventaboletos.web.utilerias.menu.item.relatorios.impressaofiscal.relatorios; + +import java.util.HashMap; + +import org.zkoss.util.resource.Labels; + +import com.rjconsultores.ventaboletos.web.utilerias.PantallaUtileria; +import com.rjconsultores.ventaboletos.web.utilerias.menu.DefaultItemMenuSistema; +import com.rjconsultores.ventaboletos.web.utilerias.menu.item.relatorios.impressaofiscal.TipoImportacaoFiscal; +import com.rjconsultores.ventaboletos.web.utilerias.menu.item.relatorios.impressaofiscal.TipoImportacaoFiscal.TipoImportacao; + +public class ItemMenuFiscalRelatorioVoucher extends DefaultItemMenuSistema { + + public ItemMenuFiscalRelatorioVoucher() { + super("indexController.mniRelatorioVoucher.label"); + } + + @Override + public String getClaveMenu() { + return "COM.RJCONSULTORES.ADMINISTRACION.GUI.RELATORIOS.IMPRESSAOFISCAL.MENU.IMPORTACIONFISCAL"; + } + + @Override + public void ejecutar() { + + @SuppressWarnings("unchecked") + HashMap map = TipoImportacaoFiscal.selecionaTipoImportacao(TipoImportacao.RELATORIO_VOUCHER, (HashMap) getArgs()); + + PantallaUtileria.openWindow("/gui/impressaofiscal/busquedaImportacionFiscal.zul", + Labels.getLabel("busquedaImportacionFiscalController.window.title"), map, desktop); + + } + +} diff --git a/web/WEB-INF/i3-label_es_MX.label b/web/WEB-INF/i3-label_es_MX.label index a98f1aa06..1586cc9b2 100644 --- a/web/WEB-INF/i3-label_es_MX.label +++ b/web/WEB-INF/i3-label_es_MX.label @@ -280,6 +280,7 @@ indexController.mniImportacionFiscalManual.label=Manual indexController.mniImportacionFiscalReducaoZ.label=Redução Z indexController.mniImportacionNaoFiscal.label=Não Fiscal indexController.mniRelatorioFinanceiro.label=Financeiro +indexController.mniRelatorioVoucher.label=Voucher indexController.mniSubMenuClientePacote.label=Paquete indexController.mniManutencaoPacote.label=Mantenimiento Paquete diff --git a/web/WEB-INF/i3-label_pt_BR.label b/web/WEB-INF/i3-label_pt_BR.label index e46e17d9e..c3b4d7a85 100644 --- a/web/WEB-INF/i3-label_pt_BR.label +++ b/web/WEB-INF/i3-label_pt_BR.label @@ -286,6 +286,7 @@ indexController.mniImportacionFiscalManual.label=Manual indexController.mniImportacionFiscalReducaoZ.label=Redução Z indexController.mniImportacionNaoFiscal.label=Não Fiscal indexController.mniRelatorioFinanceiro.label=Financeiro +indexController.mniRelatorioVoucher.label=Voucher indexController.mniSubMenuClientePacote.label=Pacote indexController.mniManutencaoPacote.label=Manutenção Pacote diff --git a/web/gui/impressaofiscal/busquedaImportacionFiscal.zul b/web/gui/impressaofiscal/busquedaImportacionFiscal.zul index 1464152b9..dffd63f8a 100644 --- a/web/gui/impressaofiscal/busquedaImportacionFiscal.zul +++ b/web/gui/impressaofiscal/busquedaImportacionFiscal.zul @@ -63,6 +63,9 @@