diff --git a/src/com/rjconsultores/ventaboletos/service/PuntoVentaService.java b/src/com/rjconsultores/ventaboletos/service/PuntoVentaService.java index 9819013e0..5d9095071 100644 --- a/src/com/rjconsultores/ventaboletos/service/PuntoVentaService.java +++ b/src/com/rjconsultores/ventaboletos/service/PuntoVentaService.java @@ -10,6 +10,7 @@ import com.rjconsultores.ventaboletos.entidad.Empresa; import com.rjconsultores.ventaboletos.entidad.Parada; import com.rjconsultores.ventaboletos.entidad.PuntoVenta; import com.rjconsultores.ventaboletos.entidad.Usuario; +import com.rjconsultores.ventaboletos.exception.BusinessException; import com.rjconsultores.ventaboletos.exception.IntegracionException; import com.rjconsultores.ventaboletos.exception.ValidacionCampoException; @@ -27,7 +28,7 @@ public interface PuntoVentaService { public PuntoVenta actualizacion(PuntoVenta entidad) throws IntegracionException, ValidacionCampoException; - public void borrar(PuntoVenta entidad); + public void borrar(PuntoVenta entidad)throws BusinessException; public List buscaLike(String strEstacion); diff --git a/src/com/rjconsultores/ventaboletos/service/impl/PuntoVentaServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/PuntoVentaServiceImpl.java index ff556c729..819006f8c 100644 --- a/src/com/rjconsultores/ventaboletos/service/impl/PuntoVentaServiceImpl.java +++ b/src/com/rjconsultores/ventaboletos/service/impl/PuntoVentaServiceImpl.java @@ -20,13 +20,16 @@ import com.rjconsultores.ventaboletos.dao.PuntoVentaDAO; import com.rjconsultores.ventaboletos.dao.UsuarioUbicacionDAO; import com.rjconsultores.ventaboletos.entidad.Constante; import com.rjconsultores.ventaboletos.entidad.Empresa; +import com.rjconsultores.ventaboletos.entidad.Estacion; import com.rjconsultores.ventaboletos.entidad.FormaPagoDet; import com.rjconsultores.ventaboletos.entidad.Parada; import com.rjconsultores.ventaboletos.entidad.PuntoVenta; import com.rjconsultores.ventaboletos.entidad.Usuario; +import com.rjconsultores.ventaboletos.exception.BusinessException; import com.rjconsultores.ventaboletos.exception.IntegracionException; import com.rjconsultores.ventaboletos.exception.ValidacionCampoException; import com.rjconsultores.ventaboletos.service.ConstanteService; +import com.rjconsultores.ventaboletos.service.EstacionService; import com.rjconsultores.ventaboletos.service.PuntoVentaService; import com.rjconsultores.ventaboletos.utilerias.ApplicationProperties; import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; @@ -56,7 +59,8 @@ public class PuntoVentaServiceImpl implements PuntoVentaService { private PuntoVentaDAO puntoVentaDAO; @Autowired private ConstanteService constanteService; - + @Autowired + private EstacionService estacionService; @Autowired private UsuarioUbicacionDAO usuarioUbicacionDAO; @@ -190,10 +194,22 @@ public class PuntoVentaServiceImpl implements PuntoVentaService { return entidad; } + + private boolean tienesEstacionEnPuntoVta(PuntoVenta entidad) { + List lsEstaciones = estacionService.buscarEstaciones(entidad); + if(lsEstaciones != null && lsEstaciones.size() > 0 ){ + return true; + } + return false; + } @Transactional - public void borrar(PuntoVenta entidad) { + public void borrar(PuntoVenta entidad) throws BusinessException{ + if(tienesEstacionEnPuntoVta(entidad)){ + throw new BusinessException("editarPuntoVentaController.MSG.estacionVinculadaAgenciaOnDelete"); + } + for (FormaPagoDet forma : entidad.getLsFormaPagoDet()) { forma.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); forma.setFecmodif(Calendar.getInstance().getTime());