diff --git a/src/com/rjconsultores/ventaboletos/dao/AliquotaEstadoDestinoDAO.java b/src/com/rjconsultores/ventaboletos/dao/AliquotaEstadoDestinoDAO.java new file mode 100644 index 000000000..dd20b3f4f --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/AliquotaEstadoDestinoDAO.java @@ -0,0 +1,12 @@ +package com.rjconsultores.ventaboletos.dao; + +import java.util.List; + +import com.rjconsultores.ventaboletos.entidad.AliquotaEstadoDestino; +import com.rjconsultores.ventaboletos.entidad.EmpresaImposto; + +public interface AliquotaEstadoDestinoDAO extends GenericDAO { + + public List getChildrens(EmpresaImposto parent); + +} diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/AliquotaEstadoDestinoHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/AliquotaEstadoDestinoHibernateDAO.java new file mode 100644 index 000000000..ad4076629 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/AliquotaEstadoDestinoHibernateDAO.java @@ -0,0 +1,41 @@ +package com.rjconsultores.ventaboletos.dao.hibernate; + +import java.util.List; + +import org.hibernate.Query; +import org.hibernate.SessionFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Repository; + +import com.rjconsultores.ventaboletos.dao.AliquotaEstadoDestinoDAO; +import com.rjconsultores.ventaboletos.entidad.AliquotaEstadoDestino; +import com.rjconsultores.ventaboletos.entidad.EmpresaImposto; + +@Repository("aliquotaEstadoDestinoDAO") +public class AliquotaEstadoDestinoHibernateDAO extends GenericHibernateDAO +implements AliquotaEstadoDestinoDAO{ + + @Autowired + public AliquotaEstadoDestinoHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) { + setSessionFactory(factory); + } + + public List getChildrens(EmpresaImposto parent){ + + StringBuilder sb = new StringBuilder(); + + sb.append(" select als from AliquotaEstadoDestino als "); + sb.append(" where als.activo = 1 "); + sb.append(" and als.empresaImposto.empresaImpostoId =:empresaImpostoId "); + sb.append(" order by als.aliquotaEstadoDestinoId "); + + Query query = getSession().createQuery(sb.toString()); + query.setParameter("empresaImpostoId", parent.getEmpresaImpostoId()); + + List lsAliquotaEstadoDestino = query.list(); + + return lsAliquotaEstadoDestino; + } + +} diff --git a/src/com/rjconsultores/ventaboletos/entidad/AliquotaEstadoDestino.java b/src/com/rjconsultores/ventaboletos/entidad/AliquotaEstadoDestino.java new file mode 100644 index 000000000..3617b9c7e --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/entidad/AliquotaEstadoDestino.java @@ -0,0 +1,123 @@ +package com.rjconsultores.ventaboletos.entidad; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +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.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.OneToOne; +import javax.persistence.SequenceGenerator; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +@Entity +@SequenceGenerator(name = "ALIQUOTAESTADODESTINO_SEQ", sequenceName = "ALIQUOTAESTADODESTINO_SEQ", allocationSize = 1) +@Table(name = "ALIQUOTA_ESTADO_DESTINO") +public class AliquotaEstadoDestino implements Serializable { + + private static final long serialVersionUID = 1L; + @Id + @GeneratedValue(strategy = GenerationType.AUTO, generator = "ALIQUOTAESTADODESTINO_SEQ") + @Basic(optional = false) + @Column(name = "ALIQUOTAESTADODESTINO_ID") + private Integer aliquotaEstadoDestinoId; + + @OneToOne + @JoinColumn(name = "ESTADO_ID") + private Estado estado; + + @Column(name = "ALIQUOTA") + private BigDecimal aliquota; + + @JoinColumn(name = "EMPRESAIMPOSTO_ID", referencedColumnName = "EMPRESAIMPOSTO_ID") + @ManyToOne + private EmpresaImposto empresaImposto; + + @Column(name = "ACTIVO") + private Boolean activo; + + @Column(name = "FECMODIF") + @Temporal(TemporalType.TIMESTAMP) + private Date fecmodif; + + @Column(name = "USUARIO_ID") + private Integer usuarioId; + + + @Override + public boolean equals(Object object) { + if (!(object instanceof AliquotaEstadoDestino)) { + return false; + } + AliquotaEstadoDestino other = (AliquotaEstadoDestino) object; + if ((this.getAliquotaEstadoDestinoId() == null && other.getAliquotaEstadoDestinoId() != null) || (this.getAliquotaEstadoDestinoId() != null && !this.getAliquotaEstadoDestinoId().equals(other.getAliquotaEstadoDestinoId()))) { + return false; + } + return true; + } + + public Integer getAliquotaEstadoDestinoId() { + return aliquotaEstadoDestinoId; + } + + public void setAliquotaEstadoDestinoId(Integer aliquotaEstadoDestinoId) { + this.aliquotaEstadoDestinoId = aliquotaEstadoDestinoId; + } + + public Estado getEstado() { + return estado; + } + + public void setEstado(Estado estado) { + this.estado = estado; + } + + public BigDecimal getAliquota() { + return aliquota; + } + + public void setAliquota(BigDecimal aliquota) { + this.aliquota = aliquota; + } + + public EmpresaImposto getEmpresaImposto() { + return empresaImposto; + } + + public void setEmpresaImposto(EmpresaImposto empresaImposto) { + this.empresaImposto = empresaImposto; + } + + public Boolean getActivo() { + return activo; + } + + public void setActivo(Boolean activo) { + this.activo = activo; + } + + public Date getFecmodif() { + return fecmodif; + } + + public void setFecmodif(Date fecmodif) { + this.fecmodif = fecmodif; + } + + public Integer getUsuarioId() { + return usuarioId; + } + + public void setUsuarioId(Integer usuarioId) { + this.usuarioId = usuarioId; + } + +} diff --git a/src/com/rjconsultores/ventaboletos/entidad/EmpresaImposto.java b/src/com/rjconsultores/ventaboletos/entidad/EmpresaImposto.java index 1e2d76efc..c9665c24a 100644 --- a/src/com/rjconsultores/ventaboletos/entidad/EmpresaImposto.java +++ b/src/com/rjconsultores/ventaboletos/entidad/EmpresaImposto.java @@ -6,9 +6,12 @@ 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; import javax.persistence.Basic; +import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; @@ -16,6 +19,7 @@ import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; +import javax.persistence.OneToMany; import javax.persistence.SequenceGenerator; import javax.persistence.Table; import javax.persistence.Temporal; @@ -53,10 +57,6 @@ public class EmpresaImposto implements Serializable { @Column(name = "INDPEDAGIOESTDUAL") private Boolean indPedadioEstdual; - @Column(name = "PORCREDMUNICIPAL") - private BigDecimal porCredMunicipal; - @Column(name = "PORCREDESTADUAL") - private BigDecimal porCredEstadual; @Column(name = "PORCREDBASEICMS") private BigDecimal porCredBaseIcms; @Column(name = "PORCREDBASEICMSIM") @@ -151,15 +151,22 @@ public class EmpresaImposto implements Serializable { @Column(name = "INDREDBASEICMSBPE") private Boolean indRedutorBaseIcmsBPe; - - @Column(name = "INDTRIBEMISSAO") - private Boolean indTribEmissao; + + @Column(name = "INDALIQUOTABPEUFDESTINO") + private Boolean indAliquotaBPeUfDestino; @Column(name = "INDTRIBVIAGEM") private Boolean indTribViagem; @Column(name = "PORCFECP") private BigDecimal porcFECP; + + + + @OneToMany(mappedBy = "empresaImposto", cascade = CascadeType.ALL, orphanRemoval=true) + private List lsAliquotaEstadoDestino; + + public EmpresaImposto() { super(); @@ -187,8 +194,9 @@ public class EmpresaImposto implements Serializable { this.indOutrasUFBloqueadas = false; this.isBPe = false; this.indRedutorBaseIcmsBPe = false; - this.indTribEmissao = false; + this.indAliquotaBPeUfDestino = false; this.indTribViagem = false; + this.lsAliquotaEstadoDestino = new ArrayList(); } /** @@ -341,35 +349,6 @@ public class EmpresaImposto implements Serializable { this.indPedadioEstdual = indPedadioEstdual; } - /** - * @return the porCredMunicipal - */ - public BigDecimal getPorCredMunicipal() { - return porCredMunicipal; - } - - /** - * @param porCredMunicipal - * the porCredMunicipal to set - */ - public void setPorCredMunicipal(BigDecimal porCredMunicipal) { - this.porCredMunicipal = porCredMunicipal; - } - - /** - * @return the porCredEstadual - */ - public BigDecimal getPorCredEstadual() { - return porCredEstadual; - } - - /** - * @param porCredEstadual - * the porCredEstadual to set - */ - public void setPorCredEstadual(BigDecimal porCredEstadual) { - this.porCredEstadual = porCredEstadual; - } /** * @return the porCredBaseIcms @@ -800,13 +779,6 @@ public class EmpresaImposto implements Serializable { this.indRedutorBaseIcmsBPe = indRedutorBaseIcmsBPe; } - public Boolean getIndTribEmissao() { - return indTribEmissao; - } - - public void setIndTribEmissao(Boolean indTribEmissao) { - this.indTribEmissao = indTribEmissao; - } public Boolean getIndTribViagem() { return indTribViagem; @@ -831,4 +803,20 @@ public class EmpresaImposto implements Serializable { public void setPorcFECP(BigDecimal porcFECP) { this.porcFECP = porcFECP; } + + public Boolean getIndAliquotaBPeUfDestino() { + return indAliquotaBPeUfDestino; + } + + public void setIndAliquotaBPeUfDestino(Boolean indAliquotaBPeUfDestino) { + this.indAliquotaBPeUfDestino = indAliquotaBPeUfDestino; + } + + public List getLsAliquotaEstadoDestino() { + return lsAliquotaEstadoDestino; + } + + public void setLsAliquotaEstadoDestino(List lsAliquotaEstadoDestino) { + this.lsAliquotaEstadoDestino = lsAliquotaEstadoDestino; + } } \ No newline at end of file diff --git a/src/com/rjconsultores/ventaboletos/service/AliquotaEstadoDestinoService.java b/src/com/rjconsultores/ventaboletos/service/AliquotaEstadoDestinoService.java new file mode 100644 index 000000000..b32b908e8 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/AliquotaEstadoDestinoService.java @@ -0,0 +1,14 @@ +package com.rjconsultores.ventaboletos.service; + +import java.util.List; + +import com.rjconsultores.ventaboletos.entidad.AliquotaEstadoDestino; +import com.rjconsultores.ventaboletos.entidad.EmpresaImposto; + +public interface AliquotaEstadoDestinoService { + + public AliquotaEstadoDestino suscribir(AliquotaEstadoDestino entidad); + + public List getChildrens(EmpresaImposto parent); + +} diff --git a/src/com/rjconsultores/ventaboletos/service/impl/AliquotaEstadoDestinoServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/AliquotaEstadoDestinoServiceImpl.java new file mode 100644 index 000000000..a247e692f --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/impl/AliquotaEstadoDestinoServiceImpl.java @@ -0,0 +1,37 @@ +package com.rjconsultores.ventaboletos.service.impl; + +import java.util.Calendar; +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.rjconsultores.ventaboletos.dao.AliquotaEstadoDestinoDAO; +import com.rjconsultores.ventaboletos.entidad.AliquotaEstadoDestino; +import com.rjconsultores.ventaboletos.entidad.EmpresaImposto; +import com.rjconsultores.ventaboletos.service.AliquotaEstadoDestinoService; +import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; + +@Service("aliquotaEstadoDestinoService") +public class AliquotaEstadoDestinoServiceImpl implements AliquotaEstadoDestinoService { + + @Autowired + private AliquotaEstadoDestinoDAO aliquotaEstadoDestinoDAO; + + @Transactional + public AliquotaEstadoDestino suscribir(AliquotaEstadoDestino entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.TRUE); + + entidad = aliquotaEstadoDestinoDAO.suscribir(entidad); + + return entidad; + } + + public List getChildrens(EmpresaImposto parent){ + return aliquotaEstadoDestinoDAO.getChildrens(parent); + } + +}