diff --git a/src/com/rjconsultores/ventaboletos/dao/HistoricoFormaPagoPuntoVentaDAO.java b/src/com/rjconsultores/ventaboletos/dao/HistoricoFormaPagoPuntoVentaDAO.java new file mode 100644 index 000000000..75966b2f0 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/HistoricoFormaPagoPuntoVentaDAO.java @@ -0,0 +1,20 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.rjconsultores.ventaboletos.dao; + +import java.util.List; + +import com.rjconsultores.ventaboletos.entidad.HistoricoFormaPagoPuntoVenta; +import com.rjconsultores.ventaboletos.entidad.PuntoVenta; + +/** + * + * @author Wallace + */ +public interface HistoricoFormaPagoPuntoVentaDAO extends GenericDAO { + + List obtenerTodosPorPuntoVenta(PuntoVenta puntoVenta); + +} diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/HistoricoFormaPagoPuntoVentaHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/HistoricoFormaPagoPuntoVentaHibernateDAO.java new file mode 100644 index 000000000..29201ff13 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/HistoricoFormaPagoPuntoVentaHibernateDAO.java @@ -0,0 +1,49 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.rjconsultores.ventaboletos.dao.hibernate; + +import java.util.List; + +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.HistoricoFormaPagoPuntoVentaDAO; +import com.rjconsultores.ventaboletos.entidad.HistoricoFormaPagoPuntoVenta; +import com.rjconsultores.ventaboletos.entidad.PuntoVenta; + +/** + * + * @author Administrador + */ +@Repository("historicoFormaPagoPuntoVentaDAO") +public class HistoricoFormaPagoPuntoVentaHibernateDAO extends GenericHibernateDAO implements HistoricoFormaPagoPuntoVentaDAO { + + @Autowired + public HistoricoFormaPagoPuntoVentaHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) { + setSessionFactory(factory); + } + + @Override + public List obtenerTodos() { + Criteria c = getSession().createCriteria(getPersistentClass()); + c.add(Restrictions.eq("activo", Boolean.TRUE)); + + return c.list(); + } + + @Override + public List obtenerTodosPorPuntoVenta(PuntoVenta puntoVenta) { + Criteria c = getSession().createCriteria(getPersistentClass()); + c.add(Restrictions.eq("activo", Boolean.TRUE)); + c.add(Restrictions.eq("puntoVenta", puntoVenta)); + + return c.list(); + } + +} diff --git a/src/com/rjconsultores/ventaboletos/entidad/HistoricoFormaPagoPuntoVenta.java b/src/com/rjconsultores/ventaboletos/entidad/HistoricoFormaPagoPuntoVenta.java new file mode 100644 index 000000000..dd31882fa --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/entidad/HistoricoFormaPagoPuntoVenta.java @@ -0,0 +1,183 @@ +package com.rjconsultores.ventaboletos.entidad; + +import java.io.Serializable; +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.SequenceGenerator; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import javax.persistence.Transient; + +import org.hibernate.Hibernate; + +import br.com.rjconsultores.auditador.annotations.AuditarClasse; +import br.com.rjconsultores.auditador.annotations.NaoAuditar; +import br.com.rjconsultores.auditador.interfaces.Auditavel; + +@AuditarClasse(nome = "HistoricoFormaPagoPuntoVenta", tela = "Alteracao Forma Pago Ponto de Venda/Historico") +@Entity +@SequenceGenerator(name = "HIST_FORMAPAGOPUNTOVENTA_SEQ", sequenceName = "HIST_FORMAPAGOPUNTOVENTA_SEQ", allocationSize = 1) +@Table(name = "HIST_FORMAPAGO_PUNTOVENTA") +public class HistoricoFormaPagoPuntoVenta implements Serializable, Auditavel { + + private static final long serialVersionUID = 1L; + @Id + @Basic(optional = false) + @GeneratedValue(strategy = GenerationType.AUTO, generator = "HIST_FORMAPAGOPUNTOVENTA_SEQ") + @Column(name = "HIST_FORMAPAGO_PUNTOVENTA_ID") + private Integer historicoFormaPagoPuntoVentaId; + + @Column(name = "IND_INCLUSAO") + private Boolean indInclusao; + + @Column(name = "MOTIVO") + private String motivo; + + @Column(name = "FEC_ALTERACAO") + @Temporal(TemporalType.TIMESTAMP) + private Date fecAlteracao; + + @NaoAuditar + @ManyToOne + @JoinColumn(name = "PUNTOVENTA_ID") + private PuntoVenta puntoVenta; + + @Column(name = "FORMAPAGO_ID") + private Integer formaPagoId; + + @Column(name = "ACTIVO") + private Boolean activo; + + @Column(name = "FECMODIF") + @Temporal(TemporalType.TIMESTAMP) + private Date fecmodif; + + @Column(name = "USUARIO_ID") + private Integer usuarioId; + + @Column(name = "EMPRESA_ID") + private Integer empresaId; + + @Transient + @NaoAuditar + private HistoricoFormaPagoPuntoVenta historicoPuntoVentaClone; + + + public Integer getHistoricoFormaPagoPuntoVentaId() { + return historicoFormaPagoPuntoVentaId; + } + + public void setHistoricoFormaPagoPuntoVentaId(Integer historicoFormaPagoPuntoVentaId) { + this.historicoFormaPagoPuntoVentaId = historicoFormaPagoPuntoVentaId; + } + + public Boolean getIndInclusao() { + return indInclusao; + } + + public void setIndInclusao(Boolean indInclusao) { + this.indInclusao = indInclusao; + } + + public Date getFecAlteracao() { + return fecAlteracao; + } + + public void setFecAlteracao(Date fecAlteracao) { + this.fecAlteracao = fecAlteracao; + } + + public HistoricoFormaPagoPuntoVenta getHistoricoPuntoVentaClone() { + return historicoPuntoVentaClone; + } + + public void setHistoricoPuntoVentaClone(HistoricoFormaPagoPuntoVenta historicoPuntoVentaClone) { + this.historicoPuntoVentaClone = historicoPuntoVentaClone; + } + + public PuntoVenta getPuntoVenta() { + return puntoVenta; + } + + public void setPuntoVenta(PuntoVenta puntoVenta) { + this.puntoVenta = puntoVenta; + } + + 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; + } + + public Integer getEmpresaId() { + return empresaId; + } + + public void setEmpresaId(Integer empresaId) { + this.empresaId = empresaId; + } + + public String getMotivo() { + return motivo; + } + + public void setMotivo(String motivo) { + this.motivo = motivo; + } + + public Integer getFormaPagoId() { + return formaPagoId; + } + + public void setFormaPagoId(Integer formaPagoId) { + this.formaPagoId = formaPagoId; + } + + @Override + public void clonar() throws CloneNotSupportedException { + historicoPuntoVentaClone = new HistoricoFormaPagoPuntoVenta(); + historicoPuntoVentaClone = (HistoricoFormaPagoPuntoVenta) this.clone(); + Hibernate.initialize(historicoPuntoVentaClone.getPuntoVenta()); + + } + + @Override + public HistoricoFormaPagoPuntoVenta getCloneObject() throws CloneNotSupportedException { + return historicoPuntoVentaClone; + } + + @Override + public String getTextoInclusaoExclusao() { + return String.format("ID [%s]", getHistoricoFormaPagoPuntoVentaId()); + } + + + +} diff --git a/src/com/rjconsultores/ventaboletos/entidad/PuntoVenta.java b/src/com/rjconsultores/ventaboletos/entidad/PuntoVenta.java index 01912897f..d77961506 100644 --- a/src/com/rjconsultores/ventaboletos/entidad/PuntoVenta.java +++ b/src/com/rjconsultores/ventaboletos/entidad/PuntoVenta.java @@ -52,7 +52,7 @@ import br.com.rjconsultores.auditador.interfaces.Auditavel; */ @Entity @SequenceGenerator(name = "PUNTO_VENTA_SEQ", sequenceName = "PUNTO_VENTA_SEQ", allocationSize = 1) -@AuditarClasse(nome = "PuntoVenta", tela = "Alteração de Ponto de Venda") +@AuditarClasse(nome = "PuntoVenta", tela = "Altera��o de Ponto de Venda") @Table(name = "PUNTO_VENTA") public class PuntoVenta implements Serializable, Auditavel { @@ -259,6 +259,11 @@ public class PuntoVenta implements Serializable, Auditavel { @LazyCollection(LazyCollectionOption.FALSE) private List historicoPuntoVentaList; + @NaoAuditar + @OneToMany(cascade = CascadeType.ALL, mappedBy = "puntoVenta") + @LazyCollection(LazyCollectionOption.FALSE) + private List historicoFormaPagoPuntoVentaList; + @AuditarLista(auditarEntidades = true, nome = "CategoriaBloqueioImpPosterior") @OneToMany(cascade = CascadeType.ALL, mappedBy = "puntoventa") @LazyCollection(LazyCollectionOption.FALSE) @@ -430,6 +435,7 @@ public class PuntoVenta implements Serializable, Auditavel { this.ptovtaCatIndList = new ArrayList(); this.ptovtaEmpresaBloqueadaList = new ArrayList(); this.historicoPuntoVentaList = new ArrayList(); + this.historicoFormaPagoPuntoVentaList = new ArrayList(); } public PuntoVenta(Integer puntoventaId) { @@ -1099,6 +1105,14 @@ public class PuntoVenta implements Serializable, Auditavel { this.historicoPuntoVentaList = historicoPuntoVentaList; } + public List getHistoricoFormaPagoPuntoVentaList() { + return historicoFormaPagoPuntoVentaList; + } + + public void setHistoricoFormaPagoPuntoVentaList(List historicoFormaPagoPuntoVentaList) { + this.historicoFormaPagoPuntoVentaList = historicoFormaPagoPuntoVentaList; + } + public List getCategoriaBloqImpPosteriorList() { return categoriaBloqImpPosteriorList; } diff --git a/src/com/rjconsultores/ventaboletos/service/HistoricoFormaPagoPuntoVentaService.java b/src/com/rjconsultores/ventaboletos/service/HistoricoFormaPagoPuntoVentaService.java new file mode 100644 index 000000000..81d8bbabc --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/HistoricoFormaPagoPuntoVentaService.java @@ -0,0 +1,21 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.rjconsultores.ventaboletos.service; + +import java.util.List; + +import com.rjconsultores.ventaboletos.entidad.HistoricoFormaPagoPuntoVenta; +import com.rjconsultores.ventaboletos.entidad.PuntoVenta; + +/** + * + * @author Wallace + */ +public interface HistoricoFormaPagoPuntoVentaService extends GenericService { + + List obtenerTodosPorPuntoVenta(PuntoVenta puntoVenta); + + +} diff --git a/src/com/rjconsultores/ventaboletos/service/impl/HistoricoFormaPagoPuntoVentaServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/HistoricoFormaPagoPuntoVentaServiceImpl.java new file mode 100644 index 000000000..27ea05e1b --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/impl/HistoricoFormaPagoPuntoVentaServiceImpl.java @@ -0,0 +1,75 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +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.HistoricoFormaPagoPuntoVentaDAO; +import com.rjconsultores.ventaboletos.entidad.HistoricoFormaPagoPuntoVenta; +import com.rjconsultores.ventaboletos.entidad.PuntoVenta; +import com.rjconsultores.ventaboletos.service.HistoricoFormaPagoPuntoVentaService; +import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; + +/** + * + * @author Wallace + */ +@Service("historicoFormaPagoPuntoVentaService") +public class HistoricoFormaPagoPuntoVentaServiceImpl implements HistoricoFormaPagoPuntoVentaService { + + @Autowired + private HistoricoFormaPagoPuntoVentaDAO historicoFormaPagoPuntoVentaDAO; + + public List obtenerTodos() { + return historicoFormaPagoPuntoVentaDAO.obtenerTodos(); + } + + public HistoricoFormaPagoPuntoVenta obtenerID(Integer id) { + return historicoFormaPagoPuntoVentaDAO.obtenerID(id); + } + + @Transactional + public HistoricoFormaPagoPuntoVenta suscribir(HistoricoFormaPagoPuntoVenta entidad) { + + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.TRUE); + entidad.setIndInclusao(Boolean.TRUE); + entidad.setFecAlteracao(Calendar.getInstance().getTime()); + + return historicoFormaPagoPuntoVentaDAO.suscribir(entidad); + } + + @Transactional + public HistoricoFormaPagoPuntoVenta actualizacion(HistoricoFormaPagoPuntoVenta entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.TRUE); + + return historicoFormaPagoPuntoVentaDAO.actualizacion(entidad); + } + + @Transactional + public void borrar(HistoricoFormaPagoPuntoVenta entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.FALSE); + entidad.setIndInclusao(Boolean.FALSE); + entidad.setFecAlteracao(Calendar.getInstance().getTime()); + + historicoFormaPagoPuntoVentaDAO.actualizacion(entidad); + } + + @Override + public List obtenerTodosPorPuntoVenta(PuntoVenta puntoVenta) { + return historicoFormaPagoPuntoVentaDAO.obtenerTodosPorPuntoVenta(puntoVenta); + } + +} diff --git a/src/com/rjconsultores/ventaboletos/service/impl/PuntoVentaServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/PuntoVentaServiceImpl.java index 798b8b03a..da64f2713 100644 --- a/src/com/rjconsultores/ventaboletos/service/impl/PuntoVentaServiceImpl.java +++ b/src/com/rjconsultores/ventaboletos/service/impl/PuntoVentaServiceImpl.java @@ -86,7 +86,7 @@ public class PuntoVentaServiceImpl implements PuntoVentaService { @Autowired private LogAuditoriaService logAuditoriaService; - // FIXME : Remover esse método de quem está usando. Esse método carrega muitos dados + // FIXME : Remover esse m�todo de quem est� usando. Esse m�todo carrega muitos dados @Deprecated public List obtenerTodos() { return puntoVentaDAO.obtenerTodos(); @@ -114,13 +114,13 @@ public class PuntoVentaServiceImpl implements PuntoVentaService { Constante constDesativaTotvs = constanteService.buscarPorNomeConstante("WS_TOTVS_DESATIVA_INTEGRACAO"); Boolean desativaTotvs = constDesativaTotvs != null && constDesativaTotvs.getValorconstante().equals("1"); - // Mantis 15739 - A integração AG deve ser acionada após a persistência dos dados com sucesso. - // Integração AG + // Mantis 15739 - A integra��o AG deve ser acionada ap�s a persist�ncia dos dados com sucesso. + // Integra��o AG /* - * Constante empresasIntegraAG = constanteService.buscarPorNomeConstante("EMPRESAS_INTEGRACAO_AG"); if (entidad.getStatusaprobacion().equals("A") && empresasIntegraAG != null && empresasIntegraAG.getValorconstante() != null && empresasIntegraAG.getValorconstante().contains(entidad.getEmpresa().getEmpresaId().toString())) { log.debug("iniciando integração com AG"); integraAG(entidad); log.debug("fim da integração com AG"); } + * Constante empresasIntegraAG = constanteService.buscarPorNomeConstante("EMPRESAS_INTEGRACAO_AG"); if (entidad.getStatusaprobacion().equals("A") && empresasIntegraAG != null && empresasIntegraAG.getValorconstante() != null && empresasIntegraAG.getValorconstante().contains(entidad.getEmpresa().getEmpresaId().toString())) { log.debug("iniciando integra��o com AG"); integraAG(entidad); log.debug("fim da integra��o com AG"); } */ - // Integração Totvs + // Integra��o Totvs if (!desativaTotvs){ if (ApplicationProperties.getInstance().isCustomHabilitado(CustomEnum.INTEGRACION_TOTVS.getDescricao())) { try { @@ -176,13 +176,13 @@ public class PuntoVentaServiceImpl implements PuntoVentaService { logAuditoriaService.auditar(null, entidad, entidad.getEmpresa() != null ? entidad.getEmpresa().getEmpresaId() : null); - // Mantis 15739 - A integração AG deve ser acionada após a persistência dos dados com sucesso. - // Integração AG + // Mantis 15739 - A integra��o AG deve ser acionada ap�s a persist�ncia dos dados com sucesso. + // Integra��o AG Constante empresasIntegraAG = constanteService.buscarPorNomeConstante("EMPRESAS_INTEGRACAO_AG"); if (entidad.getStatusaprobacion().equals("A") && empresasIntegraAG != null && empresasIntegraAG.getValorconstante() != null && empresasIntegraAG.getValorconstante().contains(entidad.getEmpresa().getEmpresaId().toString())) { - log.debug("iniciando integração com AG"); + log.debug("iniciando integra��o com AG"); integraAG(entidad); - log.debug("fim da integração com AG"); + log.debug("fim da integra��o com AG"); } return entidad; @@ -214,7 +214,7 @@ public class PuntoVentaServiceImpl implements PuntoVentaService { connection.close(); } } catch (SQLException e) { - log.error("error fechar conexão", e); + log.error("error fechar conex�o", e); throw new RuntimeException(e); } } @@ -236,9 +236,9 @@ public class PuntoVentaServiceImpl implements PuntoVentaService { return; } if (!strFornecedor.contains("ERRO")){ - // retornar msg a informação de registro já cadastrado + // retornar msg a informa��o de registro j� cadastrado entidad.setIndIntegradoAG(false); - entidad.setMotivoNaoIntegradoAG("Fornecedor já cadastrado"); + entidad.setMotivoNaoIntegradoAG("Fornecedor j� cadastrado"); } else { fornecedor = new TFornecedor(); fornecedor.setNome(entidad.getRazonSocial()); @@ -307,9 +307,9 @@ public class PuntoVentaServiceImpl implements PuntoVentaService { return; } if (!cliStr.contains("ERRO")) { - // retornar msg a informação de registro já cadastrado + // retornar msg a informa��o de registro j� cadastrado entidad.setIndIntegradoAG(false); - entidad.setMotivoNaoIntegradoAG("Cliente já cadastrado"); + entidad.setMotivoNaoIntegradoAG("Cliente j� cadastrado"); } else { cli = new TCliente(); cli.setCodigo(""); @@ -435,7 +435,7 @@ public class PuntoVentaServiceImpl implements PuntoVentaService { PuntoVenta originalClone = null; try { originalClone = entidad.getCloneObject(); - if(entidad.getTitularId()!=null) { + if(entidad.getTitularId()!=null && originalClone != null) { originalClone.setTitularId(entidad.getTitularId().getCloneObject()); } } catch (Exception e) { @@ -449,13 +449,13 @@ public class PuntoVentaServiceImpl implements PuntoVentaService { Constante constDesativaTotvs = constanteService.buscarPorNomeConstante("WS_TOTVS_DESATIVA_INTEGRACAO"); Boolean desativaTotvs = constDesativaTotvs != null && constDesativaTotvs.getValorconstante().equals("1"); - // Mantis 15739 - A integração AG deve ser acionada após a persistência dos dados com sucesso. - // Integração AG + // Mantis 15739 - A integra��o AG deve ser acionada ap�s a persist�ncia dos dados com sucesso. + // Integra��o AG /* - * Constante empresasIntegraAG = constanteService.buscarPorNomeConstante("EMPRESAS_INTEGRACAO_AG"); if ( entidad.getStatusaprobacion().equals("A") && empresasIntegraAG != null && empresasIntegraAG.getValorconstante() != null && empresasIntegraAG.getValorconstante().contains(entidad.getEmpresa().getEmpresaId().toString())) { log.debug("iniciando integração com AG"); integraAG(entidad); log.debug("fim da integração com AG"); } + * Constante empresasIntegraAG = constanteService.buscarPorNomeConstante("EMPRESAS_INTEGRACAO_AG"); if ( entidad.getStatusaprobacion().equals("A") && empresasIntegraAG != null && empresasIntegraAG.getValorconstante() != null && empresasIntegraAG.getValorconstante().contains(entidad.getEmpresa().getEmpresaId().toString())) { log.debug("iniciando integra��o com AG"); integraAG(entidad); log.debug("fim da integra��o com AG"); } */ - // Integração Totvs + // Integra��o Totvs if (!desativaTotvs){ if (ApplicationProperties.getInstance().isCustomHabilitado(CustomEnum.INTEGRACION_TOTVS.getDescricao())) { @@ -510,13 +510,13 @@ public class PuntoVentaServiceImpl implements PuntoVentaService { } } - // Mantis 15739 - A integração AG deve ser acionada após a persistência dos dados com sucesso. - // Integração AG + // Mantis 15739 - A integra��o AG deve ser acionada ap�s a persist�ncia dos dados com sucesso. + // Integra��o AG Constante empresasIntegraAG = constanteService.buscarPorNomeConstante("EMPRESAS_INTEGRACAO_AG"); if (entidad.getStatusaprobacion().equals("A") && empresasIntegraAG != null && empresasIntegraAG.getValorconstante() != null && empresasIntegraAG.getValorconstante().contains(entidad.getEmpresa().getEmpresaId().toString())) { - log.debug("iniciando integração com AG"); + log.debug("iniciando integra��o com AG"); integraAG(entidad); - log.debug("fim da integração com AG"); + log.debug("fim da integra��o com AG"); } return entidad; @@ -765,7 +765,7 @@ public class PuntoVentaServiceImpl implements PuntoVentaService { String contrib = ContribuinteICMS.NAO.getValor(); String entid = TipoEntidade.TRANSPORTE_PASSAGEIRO.getValor(); - String pais = "";// segundo orientação da TOTVS, passar em branco + String pais = "";// segundo orienta��o da TOTVS, passar em branco try { resp = TotvsService.cadastrarCliente(endpointCliente, bairro, cep, cgc, codmun, codpais, complemen, contaCliente, contrib, ddd, email, cnpjEmpresaProtheus,