diff --git a/src/com/rjconsultores/ventaboletos/service/PacoteService.java b/src/com/rjconsultores/ventaboletos/service/PacoteService.java index 1c93206dd..4f14d767d 100644 --- a/src/com/rjconsultores/ventaboletos/service/PacoteService.java +++ b/src/com/rjconsultores/ventaboletos/service/PacoteService.java @@ -1,6 +1,13 @@ package com.rjconsultores.ventaboletos.service; +import com.rjconsultores.ventaboletos.entidad.ItemAdicional; import com.rjconsultores.ventaboletos.entidad.Pacote; +import com.rjconsultores.ventaboletos.entidad.TipoTarifaPacote; public interface PacoteService extends GenericService { + + public Boolean verificaCadastroTarifa(Pacote pacote, TipoTarifaPacote tarifa); + + public Boolean verificaCadastroItemAdicional(Pacote pacote, ItemAdicional item); + } diff --git a/src/com/rjconsultores/ventaboletos/service/impl/PacoteServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/PacoteServiceImpl.java index 48fbde920..463644eea 100644 --- a/src/com/rjconsultores/ventaboletos/service/impl/PacoteServiceImpl.java +++ b/src/com/rjconsultores/ventaboletos/service/impl/PacoteServiceImpl.java @@ -8,8 +8,14 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.rjconsultores.ventaboletos.dao.PacoteDAO; +import com.rjconsultores.ventaboletos.entidad.ItemAdicional; import com.rjconsultores.ventaboletos.entidad.Pacote; +import com.rjconsultores.ventaboletos.entidad.PacoteItem; +import com.rjconsultores.ventaboletos.entidad.PacoteTarifa; +import com.rjconsultores.ventaboletos.entidad.TipoTarifaPacote; +import com.rjconsultores.ventaboletos.service.PacoteItemService; import com.rjconsultores.ventaboletos.service.PacoteService; +import com.rjconsultores.ventaboletos.service.PacoteTarifaService; import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; @Service("pacoteService") @@ -18,6 +24,12 @@ public class PacoteServiceImpl implements PacoteService { @Autowired private PacoteDAO pacoteDAO; + @Autowired + private PacoteTarifaService pacoteTarifaService; + + @Autowired + private PacoteItemService pacoteItemService; + @Override public List obtenerTodos() { return pacoteDAO.obtenerTodos(); @@ -56,4 +68,28 @@ public class PacoteServiceImpl implements PacoteService { pacoteDAO.actualizacion(entidad); } + @Override + public Boolean verificaCadastroTarifa(Pacote pacote, TipoTarifaPacote tarifa) { + + List pacoteTarifaLs = pacoteTarifaService.buscaTarifasPacote(pacote); + for (PacoteTarifa pacoteTarifa : pacoteTarifaLs) { + if (pacoteTarifa.getTipoTarifaPacote().equals(tarifa)) + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + + @Override + public Boolean verificaCadastroItemAdicional(Pacote pacote, ItemAdicional item) { + List pacoteItemLs = pacoteItemService.buscaItensPacote(pacote); + + for (PacoteItem pacoteItem : pacoteItemLs) { + if (pacoteItem.getItemAdicional().equals(item)) + return Boolean.FALSE; + } + + return Boolean.TRUE; + } + }