diff --git a/src/com/rjconsultores/ventaboletos/dao/sqlbuilder/impl/SQLBuilderOracle.java b/src/com/rjconsultores/ventaboletos/dao/sqlbuilder/impl/SQLBuilderOracle.java index 5b05716a4..ef019ccb6 100644 --- a/src/com/rjconsultores/ventaboletos/dao/sqlbuilder/impl/SQLBuilderOracle.java +++ b/src/com/rjconsultores/ventaboletos/dao/sqlbuilder/impl/SQLBuilderOracle.java @@ -21,6 +21,7 @@ public class SQLBuilderOracle implements SQLBuilder { private static final Integer RED_PAGO_FORMAPAGO_ID = Integer.valueOf(95); private static final String RED_PAGO_EMISSOR_TARJETA = "RDP"; private static final String RED_PAGO_FORMA_PAGO = "CR"; + private static final Integer DER_PR = 2; @Override public String getSQLGerarTabelaZerada(final Integer codRuta, final Integer usuarioId,final Integer orgaoConcedenteId, final List idsEmpresas){ @@ -274,25 +275,64 @@ public class SQLBuilderOracle implements SQLBuilder { sb.append(" select "); sb.append(" "); sb.append(" TARIFA_OFICIAL_SEQ.NEXTVAL, "); - + //>> SE ORGAO FOR DER-PR E SE O COEFICIENTE DA CLASSE NAO ESTA NULL + sb.append(" CASE R.ORGAOCONCEDENTE_ID WHEN "+DER_PR+" THEN CASE WHEN cl.COEFICIENTETARIFA IS NOT NULL THEN " ); + sb.append(" trunc(((coalesce(ct1.coeficiente,0) + oc.coeficientetarifa / ((POWER(COALESCE(tc.kmcoeficiente1,0) + 350,0.27)*16160 )) ) * COALESCE(tc.kmcoeficiente1,0)) * cl.COEFICIENTETARIFA " ); + sb.append(" + ((coalesce(ct2.coeficiente,0) + oc.coeficientetarifa / ((POWER(COALESCE(tc.kmcoeficiente2,0) + 350,0.27)*13470 )) ) * COALESCE(tc.kmcoeficiente2,0)) * cl.COEFICIENTETARIFA,2) " ); + sb.append(" ELSE " ); + //< COEFICIENTE DA CLASSE ESTA NULL sb.append(" ROUND( "); sb.append(" (coalesce(ct1.coeficiente,0) * coalesce(tc.kmcoeficiente1,0) + "); sb.append(" coalesce(ct2.coeficiente,0) * coalesce(tc.kmcoeficiente2,0) + "); sb.append(" coalesce(ct3.coeficiente,0) * coalesce(tc.kmcoeficiente3,0)) * "); if (orgaoConcedente != null && orgaoConcedente.getIndUtilizaICMS() != null && orgaoConcedente.getIndUtilizaICMS()) { - sb.append(" case when e.icms is null then 1 else (1/(1-e.icms/100)) end ,2) ,"); + sb.append(" case when e.icms is null then 1 else (1/(1-e.icms/100)) end ,2) "); } else { - sb.append(" 1, 2 ) ,"); + sb.append(" 1, 2 ) "); } + // + sb.append(" end else " ); + //< ORGAO NAO EH DER-PR sb.append(" ROUND( "); sb.append(" (coalesce(ct1.coeficiente,0) * coalesce(tc.kmcoeficiente1,0) + "); sb.append(" coalesce(ct2.coeficiente,0) * coalesce(tc.kmcoeficiente2,0) + "); sb.append(" coalesce(ct3.coeficiente,0) * coalesce(tc.kmcoeficiente3,0)) * "); if (orgaoConcedente != null && orgaoConcedente.getIndUtilizaICMS() != null && orgaoConcedente.getIndUtilizaICMS()) { - sb.append(" case when e.icms is null then 1 else (1/(1-e.icms/100)) end ,2) ,"); + sb.append(" case when e.icms is null then 1 else (1/(1-e.icms/100)) end ,2) "); } else { - sb.append(" 1, 2 ) ,"); + sb.append(" 1, 2 ) "); } + sb.append(" end , " ); + // + //>> SE ORGAO FOR DER-PR E SE O COEFICIENTE DA CLASSE NAO ESTA NULL + sb.append(" CASE R.ORGAOCONCEDENTE_ID WHEN "+DER_PR+" THEN CASE WHEN cl.COEFICIENTETARIFA IS NOT NULL THEN " ); + sb.append(" trunc(((coalesce(ct1.coeficiente,0) + oc.coeficientetarifa / ((POWER(COALESCE(tc.kmcoeficiente1,0) + 350,0.27)*16160 )) ) * COALESCE(tc.kmcoeficiente1,0)) * cl.COEFICIENTETARIFA " ); + sb.append(" + ((coalesce(ct2.coeficiente,0) + oc.coeficientetarifa / ((POWER(COALESCE(tc.kmcoeficiente2,0) + 350,0.27)*13470 )) ) * COALESCE(tc.kmcoeficiente2,0)) * cl.COEFICIENTETARIFA,2) " ); + sb.append(" ELSE " ); + //< COEFICIENTE DA CLASSE ESTA NULL + sb.append(" ROUND( "); + sb.append(" (coalesce(ct1.coeficiente,0) * coalesce(tc.kmcoeficiente1,0) + "); + sb.append(" coalesce(ct2.coeficiente,0) * coalesce(tc.kmcoeficiente2,0) + "); + sb.append(" coalesce(ct3.coeficiente,0) * coalesce(tc.kmcoeficiente3,0)) * "); + if (orgaoConcedente != null && orgaoConcedente.getIndUtilizaICMS() != null && orgaoConcedente.getIndUtilizaICMS()) { + sb.append(" case when e.icms is null then 1 else (1/(1-e.icms/100)) end ,2) "); + } else { + sb.append(" 1, 2 ) "); + } + // + sb.append(" end else " ); + //< ORGAO NAO EH DER-PR + sb.append(" ROUND( "); + sb.append(" (coalesce(ct1.coeficiente,0) * coalesce(tc.kmcoeficiente1,0) + "); + sb.append(" coalesce(ct2.coeficiente,0) * coalesce(tc.kmcoeficiente2,0) + "); + sb.append(" coalesce(ct3.coeficiente,0) * coalesce(tc.kmcoeficiente3,0)) * "); + if (orgaoConcedente != null && orgaoConcedente.getIndUtilizaICMS() != null && orgaoConcedente.getIndUtilizaICMS()) { + sb.append(" case when e.icms is null then 1 else (1/(1-e.icms/100)) end ,2) "); + } else { + sb.append(" 1, 2 ) "); + } + sb.append(" end , " ); + // sb.append(" t.tramo_id, "); sb.append(" mc.marca_id, "); sb.append(" r.CLASESERVICIO_ID, "); @@ -331,7 +371,8 @@ public class SQLBuilderOracle implements SQLBuilder { sb.append(" inner join ciudad c on c.ciudad_id = po.ciudad_id "); sb.append(" inner join estado e on e.estado_id = c.estado_id "); sb.append(" inner join MARCA_CLASESERVICIO mc on "); - sb.append(" mc.CLASESERVICIO_ID = r.CLASESERVICIO_ID and ma.marca_id = mc.marca_id, "); + sb.append(" mc.CLASESERVICIO_ID = r.CLASESERVICIO_ID and ma.marca_id = mc.marca_id "); + sb.append(" inner join CLASE_SERVICIO cl on cl.claseservicio_id = r.CLASESERVICIO_ID, "); sb.append(" moneda m "); sb.append(" "); sb.append("where "); diff --git a/src/com/rjconsultores/ventaboletos/entidad/ClaseServicio.java b/src/com/rjconsultores/ventaboletos/entidad/ClaseServicio.java index e6b50ddfb..7379c1de9 100644 --- a/src/com/rjconsultores/ventaboletos/entidad/ClaseServicio.java +++ b/src/com/rjconsultores/ventaboletos/entidad/ClaseServicio.java @@ -5,6 +5,7 @@ package com.rjconsultores.ventaboletos.entidad; import java.io.Serializable; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -12,17 +13,15 @@ import javax.persistence.Basic; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.OneToMany; +import javax.persistence.SequenceGenerator; import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; import org.hibernate.annotations.GenericGenerator; -import javax.persistence.SequenceGenerator; - /** * * @author Administrador @@ -67,6 +66,8 @@ public class ClaseServicio implements Serializable { private List tarifaHistList; @OneToMany(mappedBy = "claseServicio") private List corridaList; + @Column(name = "COEFICIENTETARIFA") + private BigDecimal coeficiente; public ClaseServicio() { } @@ -80,8 +81,6 @@ public class ClaseServicio implements Serializable { this.fecmodif = fecmodif; } - - public Integer getClaseservicioId() { return claseservicioId; } @@ -226,4 +225,13 @@ public class ClaseServicio implements Serializable { public void setTipoServicoBPe(Integer tipoServicoBPe) { this.tipoServicoBPe = tipoServicoBPe; } + + public BigDecimal getCoeficiente() { + return coeficiente; + } + + public void setCoeficiente(BigDecimal coeficiente) { + this.coeficiente = coeficiente; + } + } \ No newline at end of file diff --git a/src/com/rjconsultores/ventaboletos/entidad/OrgaoConcedente.java b/src/com/rjconsultores/ventaboletos/entidad/OrgaoConcedente.java index 878e17b2a..e3b68bd81 100644 --- a/src/com/rjconsultores/ventaboletos/entidad/OrgaoConcedente.java +++ b/src/com/rjconsultores/ventaboletos/entidad/OrgaoConcedente.java @@ -78,6 +78,9 @@ public class OrgaoConcedente implements Serializable { @OneToMany(mappedBy = "orgaoConcedente", cascade = CascadeType.ALL) @Where(clause = "activo=1") private List orgaoEmpParams; + + @Column(name = "COEFICIENTETARIFA") + private BigDecimal coeficiente; public void addParametro(OrgaoCancelacion param) { this.orgaoCancelacionList.add(param); @@ -250,6 +253,14 @@ public class OrgaoConcedente implements Serializable { this.indValDocObligatorioMonitrip = indValDocObligatorioMonitrip; } + public BigDecimal getCoeficiente() { + return coeficiente; + } + + public void setCoeficiente(BigDecimal coeficiente) { + this.coeficiente = coeficiente; + } + @Override public int hashCode() { final int prime = 31;