gleimar 2013-12-20 18:48:49 +00:00
parent 69340dea0f
commit bc6aa0a23d
2 changed files with 18 additions and 12 deletions

View File

@ -8,7 +8,6 @@ import java.util.List;
import com.rjconsultores.ventaboletos.entidad.Estacion;
import com.rjconsultores.ventaboletos.entidad.PuntoVenta;
import com.rjconsultores.ventaboletos.entidad.Usuario;
import com.rjconsultores.ventaboletos.exception.BusinessException;
/**
@ -31,7 +30,7 @@ public interface EstacionService {
*/
public Estacion suscribirActualizar(Estacion entidad) throws BusinessException;
public void borrar(Estacion entidad);
public void borrar(Estacion entidad) throws BusinessException;
public List<Estacion> buscar(String descEstacion, String descMac, Long nunCaja, PuntoVenta pv);

View File

@ -15,7 +15,6 @@ import com.rjconsultores.ventaboletos.dao.EstacionDAO;
import com.rjconsultores.ventaboletos.entidad.Estacion;
import com.rjconsultores.ventaboletos.entidad.EstacionSitef;
import com.rjconsultores.ventaboletos.entidad.PuntoVenta;
import com.rjconsultores.ventaboletos.entidad.Usuario;
import com.rjconsultores.ventaboletos.exception.BusinessException;
import com.rjconsultores.ventaboletos.service.AutorizaFolioService;
import com.rjconsultores.ventaboletos.service.EstacionService;
@ -46,14 +45,8 @@ public class EstacionServiceImpl implements EstacionService {
@Transactional(rollbackFor = BusinessException.class)
public Estacion suscribirActualizar(Estacion estacion) throws BusinessException {
if (!ApplicationProperties.getInstance().generarRotinaFolios()){
Estacion estacionPuntoVentaAnterior = estacionDAO.obtenerID(estacion.getEstacionId());
if (!estacionPuntoVentaAnterior.getPuntoVenta().equals(estacion.getPuntoVenta())){
if (estacionDAO.temEstoque(estacionPuntoVentaAnterior.getPuntoVenta(), estacion)){
throw new BusinessException("estacionServiceImpl.msg.hayStock");
}
}
}
validarEstoque(estacion);
Boolean esMacDuplicado = Boolean.FALSE;
List<Estacion> lsEstacionMac = estacionDAO.buscar(estacion.getDescmac());
if (!lsEstacionMac.isEmpty()) {
@ -100,8 +93,22 @@ public class EstacionServiceImpl implements EstacionService {
}
private void validarEstoque(Estacion estacion) throws BusinessException {
if (!ApplicationProperties.getInstance().generarRotinaFolios()){
Estacion estacionPuntoVentaAnterior = estacionDAO.obtenerID(estacion.getEstacionId());
if (!estacionPuntoVentaAnterior.getPuntoVenta().equals(estacion.getPuntoVenta())){
if (estacionDAO.temEstoque(estacionPuntoVentaAnterior.getPuntoVenta(), estacion)){
throw new BusinessException("estacionServiceImpl.msg.hayStock");
}
}
}
}
@Transactional
public void borrar(Estacion entidad) {
public void borrar(Estacion entidad) throws BusinessException {
validarEstoque(entidad);
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
entidad.setFecmodif(Calendar.getInstance().getTime());
entidad.setActivo(Boolean.FALSE);