marcus 2013-05-09 20:02:51 +00:00
parent d7609fc180
commit 57fee2c762
1 changed files with 23 additions and 7 deletions

View File

@ -6,6 +6,7 @@ package com.rjconsultores.ventaboletos.service.impl;
import com.rjconsultores.ventaboletos.entidad.Plaza;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Calendar;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
@ -88,13 +89,20 @@ public class TarifaServiceImpl implements TarifaService {
th = tarifaHistService.suscribir(th);
}
@Transactional
public Tarifa suscribir(Tarifa entidad) {
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
entidad.setFecmodif(Calendar.getInstance().getTime());
entidad.setActivo(Boolean.TRUE);
if (entidad.getPrecio() != null) {
entidad.setPrecio(entidad.getPrecio().setScale(2, RoundingMode.HALF_UP));
}
if (entidad.getPreciooriginal() != null) {
entidad.setPreciooriginal(entidad.getPreciooriginal().setScale(2, RoundingMode.HALF_UP));
}
if (entidad.getPrecioredabierto() != null) {
entidad.setPrecioredabierto(entidad.getPrecioredabierto().setScale(2, RoundingMode.HALF_UP));
}
cadastrarTarifaHistorico(entidad);
return tarifaDAO.suscribir(entidad);
@ -105,6 +113,15 @@ public class TarifaServiceImpl implements TarifaService {
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
entidad.setFecmodif(Calendar.getInstance().getTime());
entidad.setActivo(Boolean.TRUE);
if (entidad.getPrecio() != null) {
entidad.setPrecio(entidad.getPrecio().setScale(2, RoundingMode.HALF_UP));
}
if (entidad.getPreciooriginal() != null) {
entidad.setPreciooriginal(entidad.getPreciooriginal().setScale(2, RoundingMode.HALF_UP));
}
if (entidad.getPrecioredabierto() != null) {
entidad.setPrecioredabierto(entidad.getPrecioredabierto().setScale(2, RoundingMode.HALF_UP));
}
// Rafael: Segundo a Letícia, não pode atualizar o DOLAR caso haja uma
// atualização de preço, os dolores somente são gerados na inclusão de preço.
@ -142,7 +159,7 @@ public class TarifaServiceImpl implements TarifaService {
tarifaDAO.actualizacion(entidad);
}
public boolean existe(Marca marca, Tramo tramo, Moneda moneda,ClaseServicio claseServicio, VigenciaTarifa vigenciaTarifa, Ruta ruta, OrgaoConcedente orgaoConcedente) {
public boolean existe(Marca marca, Tramo tramo, Moneda moneda, ClaseServicio claseServicio, VigenciaTarifa vigenciaTarifa, Ruta ruta, OrgaoConcedente orgaoConcedente) {
return tarifaDAO.existe(marca, tramo, moneda, claseServicio, vigenciaTarifa, ruta, orgaoConcedente);
}
@ -162,7 +179,6 @@ public class TarifaServiceImpl implements TarifaService {
return tarifaDAO.buscarTarifasAtivasInativasPorVigencia(vigencia);
}
public Boolean podeAlterarTarifaMinima(Tarifa tarifa, Marca marca, Parada origem,
Parada destino, ClaseServicio claseServicio, Plaza plaza, Moneda moneda) {
@ -176,7 +192,7 @@ public class TarifaServiceImpl implements TarifaService {
log.debug("Moneda : " + moneda.getDescmoneda());
log.debug("Preço : " + tarifa.getPrecio());
for (TarifaMinima tm : lsTarifaMinima) {
if (tarifa.getPrecio().compareTo(tm.getImportetarifa()) == -1) {
podeAlterarTarifaMinima = Boolean.FALSE;
@ -226,7 +242,7 @@ public class TarifaServiceImpl implements TarifaService {
tarifa.setTramo(rc.getTramo());
// Tramo-Marca-Classe-Vigencia-Moneda
boolean existe = tarifaDAO.existe(tarifa.getMarca(), tarifa.getTramo(), tarifa.getMoneda(), tarifa.getClaseServicio(), tarifa.getVigenciaTarifa(), tarifa.getRuta(), tarifa.getOrgaoConcedente()) ;
boolean existe = tarifaDAO.existe(tarifa.getMarca(), tarifa.getTramo(), tarifa.getMoneda(), tarifa.getClaseServicio(), tarifa.getVigenciaTarifa(), tarifa.getRuta(), tarifa.getOrgaoConcedente());
if (!existe) {
tarifa.setFecmodif(Calendar.getInstance().getTime());
@ -242,7 +258,7 @@ public class TarifaServiceImpl implements TarifaService {
}
}
} catch (Exception e) {
log.debug("ERRO al generar tarifas" , e);
log.debug("ERRO al generar tarifas", e);
return false;
}
return true;