From 5309ad9e6891f312a2f247af8f4c57e13e2c4b22 Mon Sep 17 00:00:00 2001 From: frederico Date: Wed, 6 Jul 2016 19:51:22 +0000 Subject: [PATCH] fixed bug #7557 : correcao tela de excessao de pedagio git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Web/trunk/ventaboletos@57674 d1611594-4594-4d17-8e1d-87c2c4800839 --- .../EditarExcepcionPeajeController.java | 28 ++++++++++++++++--- .../render/RenderExcepcionPeajeVigencia.java | 3 -- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/configuracioneccomerciales/EditarExcepcionPeajeController.java b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/configuracioneccomerciales/EditarExcepcionPeajeController.java index 03afceb1e..4d5836fd4 100644 --- a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/configuracioneccomerciales/EditarExcepcionPeajeController.java +++ b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/configuracioneccomerciales/EditarExcepcionPeajeController.java @@ -1,5 +1,6 @@ package com.rjconsultores.ventaboletos.web.gui.controladores.configuracioneccomerciales; +import java.util.Date; import java.util.ArrayList; import java.util.Calendar; import java.util.Collections; @@ -133,7 +134,7 @@ public class EditarExcepcionPeajeController extends MyGenericForwardComposer { public void setRutaService(RutaService rutaService) { this.rutaService = rutaService; } - + @Override public void doAfterCompose(Component comp) throws Exception { super.doAfterCompose(comp); @@ -145,7 +146,7 @@ public class EditarExcepcionPeajeController extends MyGenericForwardComposer { if(excepcionPeaje.getExcepcionPeajeId() != null){ excepcionPeaje = excepcionPeajeService.obtenerID(excepcionPeaje.getExcepcionPeajeId()); } - lsExcepcionPeajeVigencia = excepcionPeaje.getLsExcepcionPeajeVigencia(); + lsExcepcionPeajeVigencia = getExcepcionPeajeVigenciaActivo(excepcionPeaje.getLsExcepcionPeajeVigencia()); if(lsExcepcionPeajeVigencia != null){ Collections.sort(lsExcepcionPeajeVigencia); } @@ -214,6 +215,17 @@ public class EditarExcepcionPeajeController extends MyGenericForwardComposer { txtPreco.setConstraint("no empty, no zero, no negative, /[0-9]+(\\,[0-9][0-9]?)?/"); } + private List getExcepcionPeajeVigenciaActivo(List excecoes){ + List result = new ArrayList(); + + for(ExcepcionPeajeVigencia e : excecoes){ + if(e.getActivo()){ + result.add(e); + } + } + return result; + } + public void onSelect$cmbParadaOrigemCve(Event ev) { if (cmbParadaOrigemCve.getSelectedItem() != null) { cmbParadaOrigem.setComboItemByParada((Parada) cmbParadaOrigemCve.getSelectedItem().getValue()); @@ -529,6 +541,9 @@ public class EditarExcepcionPeajeController extends MyGenericForwardComposer { private boolean isExcepcionPeajeVigenciaValida(ExcepcionPeajeVigencia novaExcepcionPeajeVigencia){ for(ExcepcionPeajeVigencia epv : lsExcepcionPeajeVigencia){ + if(!epv.getActivo()){ + continue; + } if(((DateUtil.inicioFecha((novaExcepcionPeajeVigencia.getFecVentaIni())).after(DateUtil.inicioFecha((epv.getFecVentaIni()))) || DateUtil.inicioFecha((novaExcepcionPeajeVigencia.getFecVentaIni())).compareTo(DateUtil.inicioFecha((epv.getFecVentaIni()))) == 0) && (DateUtil.inicioFecha((novaExcepcionPeajeVigencia.getFecVentaIni())).before(DateUtil.fimFecha((epv.getFecVentaFin())))) || DateUtil.inicioFecha((novaExcepcionPeajeVigencia.getFecVentaIni())).compareTo(DateUtil.fimFecha((epv.getFecVentaFin()))) == 0) || @@ -547,14 +562,19 @@ public class EditarExcepcionPeajeController extends MyGenericForwardComposer { calNovaHoraFin.set(2000, 10, 10); calEpvHoraIni.set(2000, 10, 10); calEpvHoraFin.set(2000, 10, 10); - if(calNovaHoraIni.getTime().after(calEpvHoraIni.getTime()) && calNovaHoraIni.getTime().before(calEpvHoraFin.getTime()) - || calNovaHoraFin.getTime().before(calEpvHoraFin.getTime()) && calNovaHoraFin.getTime().after(calEpvHoraIni.getTime())){ + if (isWithinRange(calNovaHoraIni.getTime(), calEpvHoraIni.getTime(), calEpvHoraFin.getTime()) + || isWithinRange(calNovaHoraFin.getTime(), calEpvHoraIni.getTime(), calEpvHoraFin.getTime())) { return false; } } } } return true; + } + + boolean isWithinRange(Date testDate, Date startDate, Date endDate) { + return testDate.getTime() >= startDate.getTime() && + testDate.getTime() <= endDate.getTime(); } private void limparInput() { diff --git a/src/java/com/rjconsultores/ventaboletos/web/utilerias/render/RenderExcepcionPeajeVigencia.java b/src/java/com/rjconsultores/ventaboletos/web/utilerias/render/RenderExcepcionPeajeVigencia.java index 8cbb84c07..621fbc29a 100644 --- a/src/java/com/rjconsultores/ventaboletos/web/utilerias/render/RenderExcepcionPeajeVigencia.java +++ b/src/java/com/rjconsultores/ventaboletos/web/utilerias/render/RenderExcepcionPeajeVigencia.java @@ -14,9 +14,6 @@ public class RenderExcepcionPeajeVigencia implements ListitemRenderer { public void render(Listitem lstm, Object o) throws Exception { ExcepcionPeajeVigencia excepcionPeajeVigencia = (ExcepcionPeajeVigencia) o; - if(!excepcionPeajeVigencia.getActivo()){ - return; - } Listcell lc; if(excepcionPeajeVigencia.getExcepcionPeajeVigenciaId() != null ){ lc = new Listcell(excepcionPeajeVigencia.getExcepcionPeajeVigenciaId().toString());