From 9abc231d792ea8b8bbe760712cea905e9c4ce957 Mon Sep 17 00:00:00 2001 From: "alexandre.lima" Date: Fri, 14 Jul 2017 19:12:24 +0000 Subject: [PATCH] Fixes Bug #0009192 git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Web/trunk/ventaboletos@71396 d1611594-4594-4d17-8e1d-87c2c4800839 --- .../tarifas/BusquedaSeguroKmController.java | 65 ++++--- .../tarifas/BusquedaTarifaController.java | 5 +- .../BusquedaTarifaOficialController.java | 4 + .../tarifas/CalcularPeajeController.java | 2 +- .../CopiarTarifaOficialController.java | 14 +- .../tarifas/EditarSeguroKmController.java | 172 +++++++++++++----- .../tarifas/GenerarTarifaOrgaoController.java | 21 ++- .../tarifas/TarifaOficialExcelController.java | 79 +++++--- 8 files changed, 262 insertions(+), 100 deletions(-) diff --git a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/tarifas/BusquedaSeguroKmController.java b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/tarifas/BusquedaSeguroKmController.java index bbc39189d..c36d95d07 100644 --- a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/tarifas/BusquedaSeguroKmController.java +++ b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/tarifas/BusquedaSeguroKmController.java @@ -4,15 +4,9 @@ */ package com.rjconsultores.ventaboletos.web.gui.controladores.tarifas; -import com.rjconsultores.ventaboletos.entidad.OrgaoConcedente; -import com.rjconsultores.ventaboletos.entidad.SeguroKm; -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.RenderTaxaEmbarqueOrgao; import java.util.HashMap; import java.util.Map; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Controller; @@ -24,6 +18,15 @@ import org.zkoss.zk.ui.event.EventListener; import org.zkoss.zul.Paging; import org.zkoss.zul.Textbox; +import com.rjconsultores.ventaboletos.entidad.OrgaoConcedente; +import com.rjconsultores.ventaboletos.entidad.SeguroKm; +import com.rjconsultores.ventaboletos.utilerias.ApplicationProperties; +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.SeguroPorIntervalo; + /** * * @author Administrador @@ -37,8 +40,17 @@ public class BusquedaSeguroKmController extends MyGenericForwardComposer { private MyListbox seguroKmList; private Paging pagingSeguroKm; private Textbox txtOrgao; + private boolean exibeTpp; - public Paging getPagingSeguroKm() { + public Textbox getTxtOrgao() { + return txtOrgao; + } + + public void setTxtOrgao(Textbox txtOrgao) { + this.txtOrgao = txtOrgao; + } + + public Paging getPagingSeguroKm() { return pagingSeguroKm; } @@ -61,12 +73,13 @@ public class BusquedaSeguroKmController extends MyGenericForwardComposer { public void setSeguroKmList(MyListbox seguroKmList) { this.seguroKmList = seguroKmList; } - + @Override public void doAfterCompose(Component comp) throws Exception { super.doAfterCompose(comp); - - seguroKmList.setItemRenderer(new RenderTaxaEmbarqueOrgao()); + exibeTpp = ApplicationProperties.getInstance().exibeTpp(); + + seguroKmList.setItemRenderer(new SeguroPorIntervalo()); seguroKmList.addEventListener("onDoubleClick", new EventListener() { @Override @@ -91,9 +104,15 @@ public class BusquedaSeguroKmController extends MyGenericForwardComposer { // args.put("seguroKm", null); args.put("seguroKmList", seguroKmList); - openWindow("/gui/tarifas/editarSeguroKm.zul", - Labels.getLabel("busquedaSeguroKmController.window.title"), - args, MODAL); + if (!exibeTpp) { + openWindow("/gui/tarifas/editarSeguroKm.zul", + Labels.getLabel("busquedaSeguroKmController.semTpp.window.title"), + args, MODAL); + } else { + openWindow("/gui/tarifas/editarSeguroKm.zul", + Labels.getLabel("busquedaSeguroKmController.window.title"), + args, MODAL); + } } private void refreshLista() { @@ -102,18 +121,14 @@ public class BusquedaSeguroKmController extends MyGenericForwardComposer { new HibernateSearchObject(OrgaoConcedente.class, pagingSeguroKm.getPageSize()); - - seguroKmBusqueda.addFilterEqual("activo", Boolean.TRUE); if (!txtOrgao.getValue().equals("")) { - seguroKmBusqueda.addFilterLike("descOrgao", - "%" + txtOrgao.getText().trim().concat("%")); + seguroKmBusqueda.addFilterLike("descOrgao", "%" + txtOrgao.getText().trim().concat("%")); } seguroKmBusqueda.addSortAsc("descOrgao"); - plwOrgao.init(seguroKmBusqueda, seguroKmList, pagingSeguroKm); if (seguroKmList.getData().length == 0) { @@ -148,8 +163,14 @@ public class BusquedaSeguroKmController extends MyGenericForwardComposer { args.put("seguroKm", tx); args.put("seguroKmList", seguroKmList); - openWindow("/gui/tarifas/editarSeguroKm.zul", - Labels.getLabel("busquedaSeguroKmController.window.title"), - args, MODAL); + if (!exibeTpp) { + openWindow("/gui/tarifas/editarSeguroKm.zul", + Labels.getLabel("busquedaSeguroKmController.semTpp.window.title"), + args, MODAL); + } else { + openWindow("/gui/tarifas/editarSeguroKm.zul", + Labels.getLabel("busquedaSeguroKmController.window.title"), + args, MODAL); + } } } diff --git a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/tarifas/BusquedaTarifaController.java b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/tarifas/BusquedaTarifaController.java index 95305cb08..88b2459d9 100644 --- a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/tarifas/BusquedaTarifaController.java +++ b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/tarifas/BusquedaTarifaController.java @@ -22,6 +22,7 @@ import org.zkoss.zk.ui.event.EventListener; import org.zkoss.zkplus.databind.BindingListModelList; import org.zkoss.zul.Button; import org.zkoss.zul.Combobox; +import org.zkoss.zul.Listheader; import org.zkoss.zul.Paging; import com.rjconsultores.ventaboletos.entidad.Categoria; @@ -48,6 +49,7 @@ import com.rjconsultores.ventaboletos.service.TipoPuntoVentaService; import com.rjconsultores.ventaboletos.service.UsuarioService; import com.rjconsultores.ventaboletos.service.ViaService; import com.rjconsultores.ventaboletos.service.VigenciaTarifaService; +import com.rjconsultores.ventaboletos.utilerias.ApplicationProperties; import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; import com.rjconsultores.ventaboletos.web.utilerias.MyGenericForwardComposer; import com.rjconsultores.ventaboletos.web.utilerias.MyListbox; @@ -126,6 +128,7 @@ public class BusquedaTarifaController extends MyGenericForwardComposer { private Parada destino; private Ruta ruta; private Via via; + private Listheader listheaderTPP; private final String PERMISSAO_EXCLUIR_TODAS_PESQUISA = "COM.RJCONSULTORES.VENTABOLETOS.GUI.ADM.PRECO.EXCLUIR.TODAS.PESQUISA"; @@ -338,7 +341,7 @@ public class BusquedaTarifaController extends MyGenericForwardComposer { @Override public void doAfterCompose(Component comp) throws Exception { super.doAfterCompose(comp); - + listheaderTPP.setVisible(ApplicationProperties.getInstance().exibeTpp()); this. cmbMarca.addEventListener("onChange", new EventListener() { @Override diff --git a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/tarifas/BusquedaTarifaOficialController.java b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/tarifas/BusquedaTarifaOficialController.java index 323f1c0b7..c4fc22075 100644 --- a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/tarifas/BusquedaTarifaOficialController.java +++ b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/tarifas/BusquedaTarifaOficialController.java @@ -21,6 +21,7 @@ import org.zkoss.zk.ui.Component; import org.zkoss.zk.ui.event.Event; import org.zkoss.zk.ui.event.EventListener; import org.zkoss.zul.Combobox; +import org.zkoss.zul.Listheader; import org.zkoss.zul.Paging; import org.zkoss.zul.Textbox; @@ -35,6 +36,7 @@ import com.rjconsultores.ventaboletos.service.ClaseServicioService; import com.rjconsultores.ventaboletos.service.MarcaService; import com.rjconsultores.ventaboletos.service.MonedaService; import com.rjconsultores.ventaboletos.service.RutaService; +import com.rjconsultores.ventaboletos.utilerias.ApplicationProperties; import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; import com.rjconsultores.ventaboletos.web.utilerias.MyGenericForwardComposer; import com.rjconsultores.ventaboletos.web.utilerias.MyListbox; @@ -88,6 +90,7 @@ public class BusquedaTarifaOficialController extends MyGenericForwardComposer { private Combobox cmbMoneda; private Combobox cmbVigenciaTarifaOficial; private MyListbox tarifaList; + private Listheader listheaderTPP; private static final Logger log = Logger.getLogger(BusquedaTarifaOficialController.class); @@ -202,6 +205,7 @@ public class BusquedaTarifaOficialController extends MyGenericForwardComposer { @Override public void doAfterCompose(Component comp) throws Exception { super.doAfterCompose(comp); + listheaderTPP.setVisible(ApplicationProperties.getInstance().exibeTpp()); tarifaList.setItemRenderer(new RenderTarifaOficial()); tarifaList.addEventListener("onDoubleClick", new EventListener() { diff --git a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/tarifas/CalcularPeajeController.java b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/tarifas/CalcularPeajeController.java index 40ea8ded6..babe8ed76 100644 --- a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/tarifas/CalcularPeajeController.java +++ b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/tarifas/CalcularPeajeController.java @@ -93,7 +93,7 @@ public class CalcularPeajeController extends MyGenericForwardComposer { public void onClick$btnCalcularPeaje(Event ev) throws InterruptedException { OrgaoConcedente orgao ; - boolean orgaoListaRutasHasIndices = true; + boolean orgaoListaRutasHasIndices = true; if(!listSelectedRutas.isEmpty()){ orgao = null; for(Ruta r : listSelectedRutas){ diff --git a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/tarifas/CopiarTarifaOficialController.java b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/tarifas/CopiarTarifaOficialController.java index 1560d8542..d2a2ec870 100644 --- a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/tarifas/CopiarTarifaOficialController.java +++ b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/tarifas/CopiarTarifaOficialController.java @@ -6,7 +6,6 @@ package com.rjconsultores.ventaboletos.web.gui.controladores.tarifas; import java.util.List; -import org.apache.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Controller; @@ -16,14 +15,15 @@ import org.zkoss.zk.ui.event.Event; import org.zkoss.zul.Combobox; import org.zkoss.zul.Messagebox; import org.zkoss.zul.Radio; +import org.zkoss.zul.Row; import com.rjconsultores.ventaboletos.entidad.Empresa; import com.rjconsultores.ventaboletos.entidad.OrgaoConcedente; import com.rjconsultores.ventaboletos.entidad.VigenciaTarifa; -import com.rjconsultores.ventaboletos.service.EmpresaService; import com.rjconsultores.ventaboletos.service.OrgaoConcedenteService; import com.rjconsultores.ventaboletos.service.TarifaOficialService; import com.rjconsultores.ventaboletos.service.VigenciaTarifaService; +import com.rjconsultores.ventaboletos.utilerias.ApplicationProperties; import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; import com.rjconsultores.ventaboletos.web.utilerias.MyGenericForwardComposer; @@ -54,14 +54,19 @@ public class CopiarTarifaOficialController extends MyGenericForwardComposer { private Radio rdComTarifa; private Radio rdComTaxaEmbarque; private Radio rdComSeguro; + private Radio rdComTPP; + private Row exibeTPP; @Override public void doAfterCompose(Component comp) throws Exception { lsVigenciaTarifa = vigenciaTarifaService.obtenerTodos(); lsEmpresa = UsuarioLogado.getUsuarioLogado().getEmpresa(); lsOrgao = orgaoConcedenteService.obtenerTodosExceto(-1); - super.doAfterCompose(comp); + if (!ApplicationProperties.getInstance().exibeTpp()) { + exibeTPP.setVisible(false); + } + } public void onClick$btnGenerarVigencia(Event ev) throws InterruptedException { @@ -71,11 +76,12 @@ public class CopiarTarifaOficialController extends MyGenericForwardComposer { Boolean calculaTarifa = (rdComTarifa.getValue() == null) ? Boolean.FALSE : rdComTarifa.isChecked(); Boolean calculaTaxaEmbarque = (rdComTaxaEmbarque.getValue() == null) ? Boolean.FALSE : rdComTaxaEmbarque.isChecked(); Boolean calculaSeguro = (rdComSeguro.getValue() == null) ? Boolean.FALSE : rdComSeguro.isChecked(); + Boolean calculaTPP = (rdComTPP.getValue() == null) ? Boolean.FALSE : rdComTPP.isChecked(); Empresa empresaSelecionada = cmbEmpresa.getSelectedItem() != null ? (Empresa) cmbEmpresa.getSelectedItem().getValue() : null; OrgaoConcedente orgaoConcedenteSelecionado = cmbOrgao.getSelectedItem() != null ? (OrgaoConcedente) cmbOrgao.getSelectedItem().getValue() : null; tarifaOficialService.copiarParaTarifa((VigenciaTarifa) cmbVigencia.getSelectedItem().getValue(), - calculaPedagio, calculaTarifa, calculaTaxaEmbarque, calculaSeguro, empresaSelecionada, orgaoConcedenteSelecionado); + calculaPedagio, calculaTarifa, calculaTaxaEmbarque, calculaSeguro, calculaTPP, empresaSelecionada, orgaoConcedenteSelecionado); Messagebox.show(Labels.getLabel("copiarTarifaOficialController.MSG.copiaOK"), Labels.getLabel("indexController.mniGenerarTarifaOrgao.label"), diff --git a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/tarifas/EditarSeguroKmController.java b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/tarifas/EditarSeguroKmController.java index 963476f52..4e10fa1d6 100644 --- a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/tarifas/EditarSeguroKmController.java +++ b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/tarifas/EditarSeguroKmController.java @@ -4,11 +4,8 @@ */ package com.rjconsultores.ventaboletos.web.gui.controladores.tarifas; -import com.rjconsultores.ventaboletos.entidad.OrgaoConcedente; import java.util.ArrayList; import java.util.Calendar; -import java.util.Collections; -import java.util.Comparator; import java.util.List; import org.apache.log4j.Logger; @@ -21,17 +18,23 @@ import org.zkoss.zk.ui.Component; import org.zkoss.zk.ui.Executions; import org.zkoss.zk.ui.event.Event; import org.zkoss.zul.Button; +import org.zkoss.zul.Combobox; +import org.zkoss.zul.Intbox; +import org.zkoss.zul.Row; +import com.rjconsultores.ventaboletos.constantes.TipoSeguro; +import com.rjconsultores.ventaboletos.entidad.OrgaoConcedente; import com.rjconsultores.ventaboletos.entidad.SeguroKm; import com.rjconsultores.ventaboletos.service.OrgaoConcedenteService; import com.rjconsultores.ventaboletos.service.SeguroKmService; +import com.rjconsultores.ventaboletos.utilerias.ApplicationProperties; 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.MyTextboxDecimal; import com.rjconsultores.ventaboletos.web.utilerias.render.RenderSeguroKm; -import org.zkoss.zul.Intbox; +import com.rjconsultores.ventaboletos.web.utilerias.render.RenderSeguroSemTpp; /** * @@ -50,14 +53,78 @@ public class EditarSeguroKmController extends MyGenericForwardComposer { private List lsSeguroKm; private List lsOrgaoConcedente; private MyListbox seguroKmList; + private MyListbox seguroKmListTpm; private MyComboboxEstandar cmbOrgao; private Button btnApagar; private Button btnAdicionarSeguroKm; private Intbox txtKm; + private Intbox txtKmSemTpp; private MyTextboxDecimal txtValor; private static Logger log = Logger.getLogger(EditarSeguroKmController.class); + private Combobox cmbTipoSeguro; + private List lsTipoSeguro = new ArrayList(); + private Boolean exibeTpp; + private Row rowExibeTpp; + private Row columTpp; + private Row columSemTpp; + + public SeguroKmService getSeguroKmService() { + return seguroKmService; + } - public Button getBtnApagar() { + public void setSeguroKmService(SeguroKmService seguroKmService) { + this.seguroKmService = seguroKmService; + } + + public MyListbox getSeguroKmListTpm() { + return seguroKmListTpm; + } + + public void setSeguroKmListTpm(MyListbox seguroKmListTpm) { + this.seguroKmListTpm = seguroKmListTpm; + } + + public Intbox getTxtKm() { + return txtKm; + } + + public void setTxtKm(Intbox txtKm) { + this.txtKm = txtKm; + } + + public MyTextboxDecimal getTxtValor() { + return txtValor; + } + + public void setTxtValor(MyTextboxDecimal txtValor) { + this.txtValor = txtValor; + } + + public Row getRowExibeTpp() { + return rowExibeTpp; + } + + public void setRowExibeTpp(Row rowExibeTpp) { + this.rowExibeTpp = rowExibeTpp; + } + + public Combobox getCmbTipoSeguro() { + return cmbTipoSeguro; + } + + public void setCmbTipoSeguro(Combobox cmbTipoSeguro) { + this.cmbTipoSeguro = cmbTipoSeguro; + } + + public List getLsTipoSeguro() { + return lsTipoSeguro; + } + + public void setLsTipoSeguro(List lsTipoSeguro) { + this.lsTipoSeguro = lsTipoSeguro; + } + + public Button getBtnApagar() { return btnApagar; } @@ -107,24 +174,48 @@ public class EditarSeguroKmController extends MyGenericForwardComposer { @Override public void doAfterCompose(Component comp) throws Exception { - + exibeTpp = ApplicationProperties.getInstance().exibeTpp(); lsOrgaoConcedente = orgaoConcedenteService.obtenerTodos(); super.doAfterCompose(comp); + + lsTipoSeguro.add(TipoSeguro.SEGURO); + lsTipoSeguro.add(TipoSeguro.TPP); orgao = (OrgaoConcedente) Executions.getCurrent().getArg().get("orgao"); //seguroKm = (SeguroKm) Executions.getCurrent().getArg().get("seguroKm"); - seguroKmList.setItemRenderer(new RenderSeguroKm()); - lsSeguroKm = new ArrayList(); + seguroKmList.setItemRenderer(new RenderSeguroKm()); + seguroKmListTpm.setItemRenderer(new RenderSeguroSemTpp()); + + lsSeguroKm = new ArrayList(); if (orgao != null && orgao.getOrgaoConcedenteId() != null) { lsSeguroKm = seguroKmService.buscarPorOrgao(orgao); seguroKmList.setData(lsSeguroKm); + seguroKmListTpm.setData(lsSeguroKm); cmbOrgao.setDisabled(Boolean.TRUE); cmbOrgao.setValue(orgao.getDescOrgao()); } + + if (!exibeTpp) { + seguroKmList.setVisible(true); + seguroKmListTpm.setVisible(false); + rowExibeTpp.setVisible(false); + columTpp.setVisible(true); + columSemTpp.setVisible(false); + txtKm.setVisible(true); + txtKmSemTpp.setVisible(false); + } else { + seguroKmList.setVisible(false); + seguroKmListTpm.setVisible(true); + rowExibeTpp.setVisible(true); + columTpp.setVisible(false); + columSemTpp.setVisible(true); + txtKm.setVisible(false); + txtKmSemTpp.setVisible(true); + } } public void onClick$btnSalvar(Event ev) throws InterruptedException { @@ -161,49 +252,19 @@ public class EditarSeguroKmController extends MyGenericForwardComposer { } } -// public void onClick$btnApagar(Event ev) throws InterruptedException { -// try { -// int resp = Messagebox.show( -// Labels.getLabel("editarSeguroKmController.MSG.borrarPergunta"), -// Labels.getLabel("editarSeguroKmController.window.title"), -// Messagebox.YES | Messagebox.NO, Messagebox.QUESTION); -// -// if (resp == Messagebox.YES) { -// -// seguroKmService.borrar(seguroKm); -// -// Messagebox.show( -// Labels.getLabel("editarSeguroKmController.MSG.borrarOK"), -// Labels.getLabel("editarSeguroKmController.window.title"), -// Messagebox.OK, Messagebox.INFORMATION); -// -// seguroKmList.removeItem(seguroKm); -// -// closeWindow(); -// } -// } catch (Exception ex) { -// log.error(ex); -// Messagebox.show( -// Labels.getLabel("MSG.Error"), -// Labels.getLabel("editarSeguroKmController.window.title"), -// Messagebox.OK, Messagebox.ERROR); -// } -// } public void onClick$btnAdicionarSeguroKm(Event ev) throws InterruptedException { - cmbOrgao.getValue(); - txtKm.getValue(); - txtValor.getValue(); if (lsSeguroKm.isEmpty()) { lsSeguroKm = seguroKmService.buscarPorOrgao((OrgaoConcedente) cmbOrgao.getSelectedItem().getValue()); seguroKmList.setData(lsSeguroKm); + seguroKmListTpm.setData(lsSeguroKm); } //ChecandoDuplicado boolean existe = false; for (SeguroKm km : lsSeguroKm) { - if (km.getKmate().equals(txtKm.getValue())) { + if ((txtKm.isVisible() && km.getKmate().equals(txtKm.getValue())) || (txtKmSemTpp.isVisible() && km.getKmate().equals(txtKmSemTpp.getValue()))) { existe = true; } } @@ -219,7 +280,12 @@ public class EditarSeguroKmController extends MyGenericForwardComposer { SeguroKm km = new SeguroKm(); km.setOrgaoconcedente((OrgaoConcedente) cmbOrgao.getSelectedItem().getValue()); - km.setKmate(txtKm.getValue()); + km.setTipoSeguro(cmbTipoSeguro.getSelectedItem() != null ? cmbTipoSeguro.getSelectedItem().getLabel() : TipoSeguro.SEGURO.toString()); + if (!exibeTpp) { + km.setKmate(txtKm.getValue()); + } else { + km.setKmate(txtKmSemTpp.getValue()); + } km.setValortaxa(txtValor.getValueDecimal()); km.setActivo(true); km.setFecmodif(Calendar.getInstance().getTime()); @@ -227,6 +293,7 @@ public class EditarSeguroKmController extends MyGenericForwardComposer { lsSeguroKm.add(km); seguroKmList.setData(lsSeguroKm); + seguroKmListTpm.setData(lsSeguroKm); cmbOrgao.setDisabled(Boolean.TRUE); limparInput(); @@ -234,11 +301,18 @@ public class EditarSeguroKmController extends MyGenericForwardComposer { } private void limparInput() { - txtKm.setConstraint(""); + if (txtKm.isVisible()) { + txtKm.setConstraint(""); + txtKm.setText(""); + txtKm.setConstraint("no empty, no zero, no negative"); + } + if (txtKmSemTpp.isVisible()) { + txtKmSemTpp.setConstraint(""); + txtKmSemTpp.setText(""); + txtKmSemTpp.setConstraint("no empty, no zero, no negative"); + } txtValor.setConstraint(""); - txtKm.setText(""); txtValor.setText(""); - txtKm.setConstraint("no empty, no zero, no negative"); txtValor.setConstraint("no empty, no zero, no negative"); } @@ -253,5 +327,15 @@ public class EditarSeguroKmController extends MyGenericForwardComposer { lsSeguroKm.remove(cd); seguroKmList.setData(lsSeguroKm); } + cd = (SeguroKm) seguroKmListTpm.getSelected(); + if (cd != null) { + cd.setActivo(Boolean.FALSE); + cd.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + cd.setFecmodif(Calendar.getInstance().getTime()); + seguroKmService.actualizacion(cd); + + lsSeguroKm.remove(cd); + seguroKmListTpm.setData(lsSeguroKm); + } } } diff --git a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/tarifas/GenerarTarifaOrgaoController.java b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/tarifas/GenerarTarifaOrgaoController.java index 3523ae0b2..7b7a81ca4 100644 --- a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/tarifas/GenerarTarifaOrgaoController.java +++ b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/tarifas/GenerarTarifaOrgaoController.java @@ -8,7 +8,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import org.apache.poi.hssf.util.HSSFColor.ORCHID; import org.hibernate.LazyInitializationException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; @@ -21,6 +20,7 @@ import org.zkoss.zul.Combobox; import org.zkoss.zul.Constraint; import org.zkoss.zul.Messagebox; +import com.rjconsultores.ventaboletos.constantes.TipoSeguro; import com.rjconsultores.ventaboletos.dao.TarifaOficialDAO; import com.rjconsultores.ventaboletos.entidad.Empresa; import com.rjconsultores.ventaboletos.entidad.OrgaoConcedente; @@ -33,6 +33,7 @@ import com.rjconsultores.ventaboletos.service.OrgaoConcedenteService; import com.rjconsultores.ventaboletos.service.RutaEmpresaService; import com.rjconsultores.ventaboletos.service.RutaService; import com.rjconsultores.ventaboletos.service.TarifaOficialService; +import com.rjconsultores.ventaboletos.utilerias.ApplicationProperties; import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; import com.rjconsultores.ventaboletos.web.utilerias.MyGenericForwardComposer; import com.rjconsultores.ventaboletos.web.utilerias.MyListbox; @@ -75,6 +76,7 @@ public class GenerarTarifaOrgaoController extends MyGenericForwardComposer { private Checkbox chkSeguro; private Checkbox chkZerarTabela; private Checkbox chkPedagio; + private Checkbox chkTipoSeguro; private List listSelectedRutas; private MyListbox selectedRutasList; private List lsEmpresaSelected; @@ -110,6 +112,10 @@ public class GenerarTarifaOrgaoController extends MyGenericForwardComposer { selectedRutasList.setItemRenderer(new RenderRutaDesc()); listSelectedRutas = new ArrayList(); lsEmpresaSelected = new ArrayList(); + + if (!ApplicationProperties.getInstance().exibeTpp()) { + chkTipoSeguro.setVisible(false); + } } public void onClick$chkZerarTabela(Event ev) @@ -122,7 +128,9 @@ public class GenerarTarifaOrgaoController extends MyGenericForwardComposer { chkTaxaEmbarque.setDisabled(true); chkSeguro.setChecked(false); chkSeguro.setDisabled(true); + chkTipoSeguro.setDisabled(true); chkPedagio.setChecked(false); + chkTipoSeguro.setChecked(false); chkPedagio.setDisabled(true); chkArredondarTaxaEmbarque.setChecked(false); chkArredondarTaxaEmbarque.setDisabled(true); @@ -132,6 +140,7 @@ public class GenerarTarifaOrgaoController extends MyGenericForwardComposer { chkTarifa.setChecked(true); chkTaxaEmbarque.setDisabled(false); chkSeguro.setDisabled(false); + chkTipoSeguro.setDisabled(false); chkPedagio.setDisabled(false); chkArredondarTaxaEmbarque.setDisabled(false); chkArredondarTaxaEmbarque.setChecked(true); @@ -181,14 +190,22 @@ public class GenerarTarifaOrgaoController extends MyGenericForwardComposer { } if (chkSeguro.isChecked()) { - tarifaOficialService.atualizarSeguro(listSelectedRutas, orgaoConcedenteId); + tarifaOficialService.atualizarSeguro(listSelectedRutas, orgaoConcedenteId, TipoSeguro.SEGURO); } + if (chkTipoSeguro.isChecked()) { + tarifaOficialService.atualizarSeguro(listSelectedRutas, orgaoConcedenteId, TipoSeguro.TPP); + } + if (chkPedagio.isChecked()) { tarifaOficialService.atualizarPedagio(); } tarifaOficialService.aplicarArredondamentoTarifa(orgaoConcedenteId, chkArredondarTaxaEmbarque.isChecked()); + + if (chkTipoSeguro.isChecked()) { + tarifaOficialService.atualizarSeguroTPP(listSelectedRutas, orgaoConcedenteId, TipoSeguro.TPP); + } long l = tarifaOficialService.obtenerCount(lsEmpresaSelected); diff --git a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/tarifas/TarifaOficialExcelController.java b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/tarifas/TarifaOficialExcelController.java index 2ad41253d..6624de2b4 100644 --- a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/tarifas/TarifaOficialExcelController.java +++ b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/tarifas/TarifaOficialExcelController.java @@ -51,6 +51,7 @@ import com.rjconsultores.ventaboletos.service.RutaCombinacionService; import com.rjconsultores.ventaboletos.service.RutaService; import com.rjconsultores.ventaboletos.service.TarifaService; import com.rjconsultores.ventaboletos.service.UsuarioEmpresaService; +import com.rjconsultores.ventaboletos.utilerias.ApplicationProperties; import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; import com.rjconsultores.ventaboletos.web.utilerias.MyGenericForwardComposer; import com.rjconsultores.ventaboletos.web.utilerias.MyListbox; @@ -348,42 +349,44 @@ public class TarifaOficialExcelController extends MyGenericForwardComposer { HSSFRow rowCabecalho = sheet1.createRow(0); - HSSFCell cell = rowCabecalho.createCell(0); + int j = 0; + HSSFCell cell = rowCabecalho.createCell(j++); cell.setCellValue( Labels.getLabel("busquedaTarifaController.lhId.label")); cell.setCellStyle(estilo); - HSSFCell cell0 = rowCabecalho.createCell(1); + HSSFCell cell0 = rowCabecalho.createCell(j++); cell0.setCellValue( Labels.getLabel("busquedaTarifaController.lhTramo.label")); cell0.setCellStyle(estilo); - HSSFCell cell1 = rowCabecalho.createCell(2); + HSSFCell cell1 = rowCabecalho.createCell(j++); cell1.setCellValue( Labels.getLabel("busquedaTarifaController.lhOrigen.label")); cell1.setCellStyle(estilo); - HSSFCell cell2 = rowCabecalho.createCell(3); + HSSFCell cell2 = rowCabecalho.createCell(j++); cell2.setCellValue( Labels.getLabel("busquedaTarifaController.lhDestino.label")); cell2.setCellStyle(estilo); - HSSFCell cell3 = rowCabecalho.createCell(4); + HSSFCell cell3 = rowCabecalho.createCell(j++); cell3.setCellValue( Labels.getLabel("busquedaTarifaController.lhRuta.label")); cell3.setCellStyle(estilo); - HSSFCell cell4 = rowCabecalho.createCell(5); + HSSFCell cell4 = rowCabecalho.createCell(j++); cell4.setCellValue( Labels.getLabel("busquedaTarifaController.lhMarca.label")); cell4.setCellStyle(estilo); //Preco original I - 6 - HSSFCell cell5 = rowCabecalho.createCell(6); + HSSFCell cell5 = rowCabecalho.createCell(j++); cell5.setCellValue( Labels.getLabel("busquedaTarifaController.lhClaseServicio.label")); cell5.setCellStyle(estilo); + j++; // H - 6 // HSSFCell cell6 = rowCabecalho.createCell(7); // cell6.setCellValue( @@ -391,43 +394,49 @@ public class TarifaOficialExcelController extends MyGenericForwardComposer { // cell6.setCellStyle(estilo); //I - 8 - HSSFCell cell7 = rowCabecalho.createCell(8); + HSSFCell cell7 = rowCabecalho.createCell(j++); cell7.setCellValue( Labels.getLabel("busquedaTarifaController.lhMoneda.label")); cell7.setCellStyle(estilo); //J - 9 - HSSFCell cell8 = rowCabecalho.createCell(9); + HSSFCell cell8 = rowCabecalho.createCell(j++); cell8.setCellValue( Labels.getLabel("busquedaTarifaController.lhPrecioOriginal.label")); cell8.setCellStyle(estilo); //J - 9 - HSSFCell cell9 = rowCabecalho.createCell(10); + HSSFCell cell9 = rowCabecalho.createCell(j++); cell9.setCellValue( Labels.getLabel("busquedaTarifaController.lhPrecioExcel.label")); cell9.setCellStyle(estilo); //h - 10 - HSSFCell cell10 = rowCabecalho.createCell(11); + HSSFCell cell10 = rowCabecalho.createCell(j++); cell10.setCellValue("Taxa"); cell10.setCellStyle(estilo); - HSSFCell cell11 = rowCabecalho.createCell(12); + HSSFCell cell11 = rowCabecalho.createCell(j++); cell11.setCellValue("Seguro"); cell11.setCellStyle(estilo); - HSSFCell cell12 = rowCabecalho.createCell(13); - cell12.setCellValue("Pedagio"); - cell12.setCellStyle(estilo); - - HSSFCell cell13 = rowCabecalho.createCell(14); - cell13.setCellValue("Outros"); + if (ApplicationProperties.getInstance().exibeTpp()) { + HSSFCell cell12 = rowCabecalho.createCell(j++); + cell12.setCellValue("TPP"); + cell12.setCellStyle(estilo); + } + + HSSFCell cell13 = rowCabecalho.createCell(j++); + cell13.setCellValue("Pedagio"); cell13.setCellStyle(estilo); - HSSFCell cell14 = rowCabecalho.createCell(15); - cell14.setCellValue("Total"); + HSSFCell cell14 = rowCabecalho.createCell(j++); + cell14.setCellValue("Outros"); cell14.setCellStyle(estilo); + + HSSFCell cell15 = rowCabecalho.createCell(j++); + cell15.setCellValue("Total"); + cell15.setCellStyle(estilo); } HSSFRow row = sheet1.createRow(contRow++); @@ -458,9 +467,21 @@ public class TarifaOficialExcelController extends MyGenericForwardComposer { BigDecimal taxa = tx == null ? new BigDecimal(BigInteger.ZERO) : BigDecimal.valueOf(Double.valueOf(tx)); String seg = obj[17] == null ? "0" : obj[17].toString(); BigDecimal seguro = seg == null ? new BigDecimal(BigInteger.ZERO) : BigDecimal.valueOf(Double.valueOf(seg)); - String ped = obj[18] == null ? "0" : obj[18].toString(); + + String tpp; + String ped; + String otr; + BigDecimal seguroTpp = null; + if (ApplicationProperties.getInstance().exibeTpp()) { + tpp = obj[18] == null ? "0" : obj[18].toString(); + ped = obj[19] == null ? "0" : obj[19].toString(); + otr = obj[20] == null ? "0" : obj[20].toString(); + seguroTpp = tpp == null ? new BigDecimal(BigInteger.ZERO) : BigDecimal.valueOf(Double.valueOf(tpp)); + } else { + ped = obj[18] == null ? "0" : obj[19].toString(); + otr = obj[19] == null ? "0" : obj[20].toString(); + } BigDecimal pedagio = ped == null ? new BigDecimal(BigInteger.ZERO) : BigDecimal.valueOf(Double.valueOf(ped)); - String otr = obj[19] == null ? "0" : obj[19].toString(); BigDecimal outros = otr == null ? new BigDecimal(BigInteger.ZERO) : BigDecimal.valueOf(Double.valueOf(otr)); row.createCell(9).setCellValue(original.setScale(2).doubleValue()); @@ -468,10 +489,16 @@ public class TarifaOficialExcelController extends MyGenericForwardComposer { row.createCell(11).setCellValue(taxa.setScale(2).doubleValue()); row.createCell(12).setCellValue(seguro.setScale(2).doubleValue()); - row.createCell(13).setCellValue(pedagio.setScale(2).doubleValue()); - row.createCell(14).setCellValue(outros.setScale(2).doubleValue()); - - row.createCell(15).setCellValue(atual.add(taxa).add(seguro).add(pedagio).add(outros).setScale(2).doubleValue()); + if (ApplicationProperties.getInstance().exibeTpp()) { + row.createCell(13).setCellValue(seguroTpp.setScale(2).doubleValue()); + row.createCell(14).setCellValue(pedagio.setScale(2).doubleValue()); + row.createCell(15).setCellValue(outros.setScale(2).doubleValue()); + row.createCell(16).setCellValue(atual.add(taxa).add(seguro).add(pedagio).add(outros).setScale(2).doubleValue()); + } else { + row.createCell(13).setCellValue(pedagio.setScale(2).doubleValue()); + row.createCell(14).setCellValue(outros.setScale(2).doubleValue()); + row.createCell(15).setCellValue(atual.add(taxa).add(seguro).add(pedagio).add(outros).setScale(2).doubleValue()); + } // novo preco: // BigDecimal novoPrecio = atual;