diff --git a/src/com/rjconsultores/ventaboletos/constantes/ConstantesFuncionSistema.java b/src/com/rjconsultores/ventaboletos/constantes/ConstantesFuncionSistema.java index 60a425ae8..aeba502c2 100644 --- a/src/com/rjconsultores/ventaboletos/constantes/ConstantesFuncionSistema.java +++ b/src/com/rjconsultores/ventaboletos/constantes/ConstantesFuncionSistema.java @@ -22,7 +22,7 @@ public class ConstantesFuncionSistema { public static final String CLAVE_CONFIGURACAO_VENDA_EMBARCADA = "COM.RJCONSULTORES.ADMINISTRACION.GUI.ESQUEMAOPERACIONAL.MENU.CONFVENDAEMBARCADA"; public static final String CLAVE_RELATORIO_VENDA_EMBARCADA = "COM.RJCONSULTORES.ADMINISTRACION.GUI.RELATORIOS.MENU.RELATORIOVENDAEMBARCADA"; public static final String CLAVE_CONTINGENCIA = "COM.RJCONSULTORES.ADMINISTRACION.GUI.SEGURIDAD.MENU.CONTINGENCIA"; - + public static final String CLAVE_TROCO_SIMPLES = "COM.RJCONSULTORES.ADMINISTRACION.GUI.ESQUEMAOPERACIONAL.MENU.TROCOSIMPLES"; } diff --git a/src/com/rjconsultores/ventaboletos/dao/EmpresaTrocoSimplesDAO.java b/src/com/rjconsultores/ventaboletos/dao/EmpresaTrocoSimplesDAO.java new file mode 100644 index 000000000..0307f4848 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/EmpresaTrocoSimplesDAO.java @@ -0,0 +1,8 @@ +package com.rjconsultores.ventaboletos.dao; + +import com.rjconsultores.ventaboletos.entidad.EmpresaTrocoSimples; + +public interface EmpresaTrocoSimplesDAO extends GenericDAO { + + public EmpresaTrocoSimples buscarPorEmpresaId(Integer empresaId); +} diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/EmpresaTrocoSimplesHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/EmpresaTrocoSimplesHibernateDAO.java new file mode 100644 index 000000000..42fff2c6b --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/EmpresaTrocoSimplesHibernateDAO.java @@ -0,0 +1,30 @@ +package com.rjconsultores.ventaboletos.dao.hibernate; + +import org.hibernate.Criteria; +import org.hibernate.SessionFactory; +import org.hibernate.criterion.Restrictions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Repository; + +import com.rjconsultores.ventaboletos.dao.EmpresaTrocoSimplesDAO; +import com.rjconsultores.ventaboletos.entidad.EmpresaTrocoSimples; + +@Repository("empresaTrocoSimplesDAO") +public class EmpresaTrocoSimplesHibernateDAO extends GenericHibernateDAO implements EmpresaTrocoSimplesDAO { + + @Autowired + public EmpresaTrocoSimplesHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) { + setSessionFactory(factory); + } + + @Override + public EmpresaTrocoSimples buscarPorEmpresaId(Integer empresaId) { + Criteria c = getSession().createCriteria(getPersistentClass()); + c.add(Restrictions.eq("activo", Boolean.TRUE)); + c.add(Restrictions.eq("empresa.empresaId", empresaId)); + + return (EmpresaTrocoSimples) c.uniqueResult(); + } + +} diff --git a/src/com/rjconsultores/ventaboletos/entidad/EmpresaTrocoSimples.java b/src/com/rjconsultores/ventaboletos/entidad/EmpresaTrocoSimples.java new file mode 100644 index 000000000..60e70d845 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/entidad/EmpresaTrocoSimples.java @@ -0,0 +1,167 @@ +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 +@Table(name = "EMPRESA_TROCOSIMPLES") +@SequenceGenerator(name = "EMPRESA_TROCOSIMPLES_SEQ", sequenceName = "EMPRESA_TROCOSIMPLES_SEQ", allocationSize = 1) +public class EmpresaTrocoSimples implements Serializable { + + private static final long serialVersionUID = 1L; + + @Id + @Basic(optional = false) + @GeneratedValue(strategy = GenerationType.AUTO, generator = "EMPRESA_TROCOSIMPLES_SEQ") + @Column(name = "EMPRESA_TROCOSIMPLES_ID") + private Long empresaTrocoSimplesId; + + @ManyToOne + @JoinColumn(name = "EMPRESA_ID", referencedColumnName = "EMPRESA_ID") + private Empresa empresa; + + @Column(name = "RAZAO_SOCIAL") + private String razaoSocial; + + @Column(name = "NOME_FANTASIA") + private String nomeFantasia; + + @Column(name = "CNPJ") + private String cnpj; + + @Column(name = "TELEFONE") + private String telefone; + + @Column(name = "ENDERECO") + private String endereco; + + @Column(name = "VALOR_SUGERIR_TROCO") + private BigDecimal valorSugerirTroco; + + @Column(name = "TOKEN_EMPRESA") + private String tokenEmpresa; + + @Column(name = "ACTIVO") + private Boolean activo; + + @Column(name = "FECMODIF") + @Temporal(TemporalType.TIMESTAMP) + private Date fecmodif; + + @OneToOne + @JoinColumn(name = "USUARIO_ID") + private Usuario usuario; + + public Long getEmpresaTrocoSimplesId() { + return empresaTrocoSimplesId; + } + + public void setEmpresaTrocoSimplesId(Long empresaTrocoSimplesId) { + this.empresaTrocoSimplesId = empresaTrocoSimplesId; + } + + public Empresa getEmpresa() { + return empresa; + } + + public void setEmpresa(Empresa empresa) { + this.empresa = empresa; + } + + public String getRazaoSocial() { + return razaoSocial; + } + + public void setRazaoSocial(String razaoSocial) { + this.razaoSocial = razaoSocial; + } + + public String getNomeFantasia() { + return nomeFantasia; + } + + public void setNomeFantasia(String nomeFantasia) { + this.nomeFantasia = nomeFantasia; + } + + public String getCnpj() { + return cnpj; + } + + public void setCnpj(String cnpj) { + this.cnpj = cnpj; + } + + public String getTelefone() { + return telefone; + } + + public void setTelefone(String telefone) { + this.telefone = telefone; + } + + public String getEndereco() { + return endereco; + } + + public void setEndereco(String endereco) { + this.endereco = endereco; + } + + public BigDecimal getValorSugerirTroco() { + return valorSugerirTroco; + } + + public void setValorSugerirTroco(BigDecimal valorSugerirTroco) { + this.valorSugerirTroco = valorSugerirTroco; + } + + public String getTokenEmpresa() { + return tokenEmpresa; + } + + public void setTokenEmpresa(String tokenEmpresa) { + this.tokenEmpresa = tokenEmpresa; + } + + 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 Usuario getUsuario() { + return usuario; + } + + public void setUsuario(Usuario usuario) { + this.usuario = usuario; + } + +} diff --git a/src/com/rjconsultores/ventaboletos/service/EmpresaTrocoSimplesService.java b/src/com/rjconsultores/ventaboletos/service/EmpresaTrocoSimplesService.java new file mode 100644 index 000000000..2724db514 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/EmpresaTrocoSimplesService.java @@ -0,0 +1,14 @@ +package com.rjconsultores.ventaboletos.service; + +import com.rjconsultores.ventaboletos.entidad.EmpresaTrocoSimples; +import com.rjconsultores.ventaboletos.exception.BusinessException; + +public interface EmpresaTrocoSimplesService { + + EmpresaTrocoSimples suscribirActualizar(EmpresaTrocoSimples empresaTroco) throws BusinessException; + + void apagar(EmpresaTrocoSimples empresaTroco) throws BusinessException; + + EmpresaTrocoSimples buscarEmpresaTrocoSimplesPorEmpresaId(Integer empresaID); + +} diff --git a/src/com/rjconsultores/ventaboletos/service/impl/EmpresaTrocoSimplesServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/EmpresaTrocoSimplesServiceImpl.java new file mode 100644 index 000000000..35bb2d833 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/impl/EmpresaTrocoSimplesServiceImpl.java @@ -0,0 +1,47 @@ +package com.rjconsultores.ventaboletos.service.impl; + +import java.util.Date; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.rjconsultores.ventaboletos.dao.EmpresaTrocoSimplesDAO; +import com.rjconsultores.ventaboletos.entidad.EmpresaTrocoSimples; +import com.rjconsultores.ventaboletos.exception.BusinessException; +import com.rjconsultores.ventaboletos.service.EmpresaTrocoSimplesService; +import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; + +@Service("empresaTrocoSimplesService") +public class EmpresaTrocoSimplesServiceImpl implements EmpresaTrocoSimplesService { + + @Autowired + private EmpresaTrocoSimplesDAO empresaTrocoDAO; + + @Transactional(rollbackFor = BusinessException.class) + @Override + public EmpresaTrocoSimples suscribirActualizar(EmpresaTrocoSimples empresaTroco) throws BusinessException { + + empresaTroco.setFecmodif(new Date()); + empresaTroco.setUsuario(UsuarioLogado.getUsuarioLogado()); + + if (empresaTroco.getEmpresaTrocoSimplesId() == null) { + empresaTroco = empresaTrocoDAO.suscribir(empresaTroco); + } else { + empresaTroco = empresaTrocoDAO.actualizacion(empresaTroco); + } + + return empresaTroco; + } + + @Transactional + @Override + public void apagar(EmpresaTrocoSimples empresaTroco) throws BusinessException { + empresaTrocoDAO.borrar(empresaTroco); + } + + @Override + public EmpresaTrocoSimples buscarEmpresaTrocoSimplesPorEmpresaId(Integer empresaID) { + return empresaTrocoDAO.buscarPorEmpresaId(empresaID); + } +}