daniel.zauli 2016-11-24 20:26:29 +00:00
parent fe0403f108
commit d53440ebc0
6 changed files with 49 additions and 7 deletions

View File

@ -45,7 +45,8 @@ public class Constantes {
public static Short TURNO_AUTOMATICO = new Short("99");
public static List<Integer> ORGAOS_CONCEDENTES_CALCULO_ARTESP = new ArrayList<Integer>(Arrays.asList(new Integer[]{21})) ;
public static List<Integer> ORGAOS_CONCEDENTES_CALCULO_ANTT = new ArrayList<Integer>(Arrays.asList(new Integer[]{3,9,15,22,23}));
public static List<Integer> ORGAOS_CONCEDENTES_CALCULO_ANTT = new ArrayList<Integer>(Arrays.asList(new Integer[]{3,9,15,22}));
public static List<Integer> ORGAOS_CONCEDENTES_CALCULO_AGER = new ArrayList<Integer>(Arrays.asList(new Integer[]{23}));
public static String CLAVE_EDITAR_COMISSAO = "COM.RJCONSULTORES.ADMINISTRACION.PUNTOVENTA.EDITARCOMISSAO";
public static String CLAVE_REABRIR_MOVIMENTODIARIO = "COM.RJCONSULTORES.ADMINISTRACION.GUI.COMISSAO.MENU.CONFERENCIACOMISSAO.REABRIRMOVIMENTODIARIO";

View File

@ -45,6 +45,8 @@ public interface RutaCombinacionDAO extends GenericDAO<RutaCombinacion, Integer>
public RutaCombinacion busquedaTramoRutaOrigemDestino(Ruta ruta, Parada origem, Parada destino);
public RutaCombinacion busquedaTramoRutaOrigemDestino(Integer ruta, Integer origem, Integer destino);
public List<RutaCombinacion> obtenerPorRuta(Ruta ruta);
public boolean buscarRutaCombinacionExisteTramo(Tramo tramo);

View File

@ -31,7 +31,9 @@ import com.rjconsultores.ventaboletos.entidad.ExcepcionPeajeVigencia;
import com.rjconsultores.ventaboletos.entidad.OrgaoConcedente;
import com.rjconsultores.ventaboletos.entidad.Parada;
import com.rjconsultores.ventaboletos.entidad.Ruta;
import com.rjconsultores.ventaboletos.entidad.RutaCombinacion;
import com.rjconsultores.ventaboletos.service.OrgaoConcedenteService;
import com.rjconsultores.ventaboletos.service.RutaCombinacionService;
import com.rjconsultores.ventaboletos.utilerias.ApplicationProperties;
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
@ -42,6 +44,9 @@ public class CalcularPeajeHibernateDAO extends GenericHibernateDAO<String, Strin
@Autowired
private OrgaoConcedenteService orgaoConcedenteService;
@Autowired
private RutaCombinacionService rutaCombinacionService;
@Autowired
public CalcularPeajeHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
setSessionFactory(factory);
@ -138,7 +143,11 @@ public class CalcularPeajeHibernateDAO extends GenericHibernateDAO<String, Strin
List<Object> lsObj = buscarCasetasPeajeWithinTramo(ruta);
if (null != lsObj) {
for (Object arrObj : lsObj) {
peajes.add(PeajeVO.create(ruta, orgao, (Object[]) arrObj, classeIndicePeajes, usaICMS));
Integer origenId = Integer.parseInt(((Object[]) arrObj)[8].toString());
Integer destinoId = Integer.parseInt(((Object[]) arrObj)[9].toString());
RutaCombinacion rcom = rutaCombinacionService.busquedaTramoRutaOrigemDestino(ruta.getRutaId(), origenId, destinoId);
BigDecimal bigKm = rcom.getTramo().getKmReal();
peajes.add(PeajeVO.create(ruta, orgao, (Object[]) arrObj, classeIndicePeajes, usaICMS, bigKm));
}
}
}
@ -325,6 +334,10 @@ public class CalcularPeajeHibernateDAO extends GenericHibernateDAO<String, Strin
}
}
private static BigDecimal calculateImportePeajeAGER(BigDecimal km) {
return km.multiply(new BigDecimal(0.004895f)).setScale(HIGH_PRECISION, RoundingMode.HALF_UP); // esse valor deveria vir do indice do orgao mas as casas decimais nao sao compativeis.. verificar se pode mudar a precisao do campo de indice..
}
// ((importe * rutaCantEixos) / (indice)) / ( 1 - icms)
private static BigDecimal calculateImportePeajeARTESP(BigDecimal importe, BigDecimal icms,
BigDecimal indice, BigDecimal rutaCantEixos, boolean usaICMS) {
@ -339,7 +352,7 @@ public class CalcularPeajeHibernateDAO extends GenericHibernateDAO<String, Strin
}
private static BigDecimal calculateImportePeaje(Ruta ruta, OrgaoConcedente orgao, Object[] obj, BigDecimal indicePeaje, boolean usaICMS) {
private static BigDecimal calculateImportePeaje(Ruta ruta, OrgaoConcedente orgao, Object[] obj, BigDecimal indicePeaje, boolean usaICMS, BigDecimal km) {
BigDecimal rutaCantEixos = getCantEixos(ruta);
BigDecimal indice = indicePeaje;
BigDecimal importe = getImporte(ruta, obj);
@ -348,9 +361,12 @@ public class CalcularPeajeHibernateDAO extends GenericHibernateDAO<String, Strin
if (Constantes.ORGAOS_CONCEDENTES_CALCULO_ARTESP.contains(orgao.getOrgaoConcedenteId())) {
return calculateImportePeajeARTESP(importe, icms, indice, rutaCantEixos, usaICMS);
}
if (Constantes.ORGAOS_CONCEDENTES_CALCULO_ANTT.contains(orgao.getOrgaoConcedenteId()) || orgao.getDescOrgao().equals("AGEPAN")) {
if (Constantes.ORGAOS_CONCEDENTES_CALCULO_ANTT.contains(orgao.getOrgaoConcedenteId())) {
return calculateImportePeajeANTT(importe, icms, indice, rutaCantEixos, getRutaCantAsientos(ruta), usaICMS);
}
if (Constantes.ORGAOS_CONCEDENTES_CALCULO_AGER.contains(orgao.getOrgaoConcedenteId())) {
return calculateImportePeajeAGER(km);
}
return BigDecimal.ZERO; // TODO throw an exception? como calcular quando é outro orgao concendente?
}
@ -367,7 +383,7 @@ public class CalcularPeajeHibernateDAO extends GenericHibernateDAO<String, Strin
}
private static PeajeVO create(Ruta ruta, OrgaoConcedente orgao,
Object[] obj, List<ClasseIndicePeaje> lsClasseIndicePeaje, boolean usaICMS) {
Object[] obj, List<ClasseIndicePeaje> lsClasseIndicePeaje, boolean usaICMS, BigDecimal km) {
PeajeVO pvo = new PeajeVO();
@ -379,7 +395,7 @@ public class CalcularPeajeHibernateDAO extends GenericHibernateDAO<String, Strin
pvo.orgaoId = orgao.getOrgaoConcedenteId();
pvo.casetaPeajeId = Integer.parseInt(obj[20].toString());
pvo.indicePeaje = getIndicePeaje(ruta.getClaseServicio(), orgao, lsClasseIndicePeaje);
pvo.importePeaje = calculateImportePeaje(ruta, orgao, obj, pvo.indicePeaje, usaICMS);
pvo.importePeaje = calculateImportePeaje(ruta, orgao, obj, pvo.indicePeaje, usaICMS, km);
pvo.activo = 1;
pvo.fecmodif = new Date();

View File

@ -128,6 +128,23 @@ public class RutaCombinacionHibernateDAO extends GenericHibernateDAO<RutaCombina
}
public RutaCombinacion busquedaTramoRutaOrigemDestino(Integer rutaId, Integer origemId, Integer destinoId) {
Criteria c = this.makeCriteria();
c.add(Restrictions.eq("ruta.rutaId", rutaId));
Criteria c2 = c.createCriteria("tramo");
c2.add(Restrictions.eq("origem.paradaId", origemId));
c2.add(Restrictions.eq("destino.paradaId", destinoId));
c2.add(Restrictions.eq("activo", Boolean.TRUE));
if (c.list().size() > 0) {
return (RutaCombinacion) c.list().get(0);
}
return null;
}
public List<RutaCombinacion> obtenerPorRuta(Ruta ruta) {
Criteria c = this.makeCriteria();
c.add(Restrictions.eq("ruta", ruta));

View File

@ -36,6 +36,8 @@ public interface RutaCombinacionService extends GenericService<RutaCombinacion,
public RutaCombinacion busquedaTramoRutaOrigemDestino(Ruta ruta, Parada origem, Parada destino);
public RutaCombinacion busquedaTramoRutaOrigemDestino(Integer rutaId, Integer origemId, Integer destinoId);
/**
* Regreso el tramo de la entidade RutaCobinacion donde el tramo tines el origen-destino igual y la Rua sea la misma de RutaCombinacion
*

View File

@ -112,6 +112,10 @@ public class RutaCombinacionServiceImpl implements RutaCombinacionService {
return rutaCombinacionDAO.busquedaTramoRutaOrigemDestino(ruta, origem, destino);
}
public RutaCombinacion busquedaTramoRutaOrigemDestino(Integer ruta, Integer origemId, Integer destinoId) {
return rutaCombinacionDAO.busquedaTramoRutaOrigemDestino(ruta, origemId, destinoId);
}
public List<RutaCombinacion> obtenerPorRuta(Ruta ruta) {
return rutaCombinacionDAO.obtenerPorRuta(ruta);
}