/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
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.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;

/**
 *
 * @author Rafael
 */
@AuditarClasse(nome = "PtovtaAntecipacomissao", tela = "auditarClasse.PtovtaAntecipacomissao")
@Entity
@SequenceGenerator(name = "PTOVTA_ANTECIPACOMISSAO_SEQ", sequenceName = "PTOVTA_ANTECIPACOMISSAO_SEQ", allocationSize = 1)
@Table(name = "PTOVTA_ANTECIPACOMISSAO")

public class PtovtaAntecipacomissao implements Serializable,  Auditavel<PtovtaAntecipacomissao>{
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @GeneratedValue(strategy = GenerationType.AUTO, generator = "PTOVTA_ANTECIPACOMISSAO_SEQ")
    @Column(name = " PTOVTAANTECIPACOMISSAO_ID")
    private Integer ptovtaAntecipaComissaoId;
   
    @Column(name = "DATA")
    @Temporal(TemporalType.TIMESTAMP)
    private Date data;
    
    @Column(name = "RETEM")
    private BigDecimal retem;
    @Basic(optional = false)
    @Column(name = "PERCENTUAL")
    private BigDecimal percentual;
    
    @Column(name = "ACTIVO")
    private Boolean activo;
   
    @Column(name = "FECMODIF")
    @Temporal(TemporalType.TIMESTAMP)
    private Date fecmodif;
   
    @Column(name = "USUARIO_ID")
    private int usuarioId;
    
    @JoinColumn(name = "PUNTOVENTA_ID", referencedColumnName = "PUNTOVENTA_ID")
    @ManyToOne
    private PuntoVenta puntoventaId;
    
    @Transient
	@NaoAuditar
	private PtovtaAntecipacomissao ptovtaAntecipacomissaoClone;

    public PtovtaAntecipacomissao() {
    }

    public PtovtaAntecipacomissao(Integer ptovtaAntecipaComissaoId) {
        this.ptovtaAntecipaComissaoId = ptovtaAntecipaComissaoId;
    }

    public PtovtaAntecipacomissao(Integer ptovtaAntecipaComissaoId, Date data, BigDecimal retem, BigDecimal percentual, Boolean activo, Date fecmodif, int usuarioId) {
        this.ptovtaAntecipaComissaoId = ptovtaAntecipaComissaoId;
        this.data = data;
        this.retem = retem;
        this.percentual = percentual;
        this.activo = activo;
        this.fecmodif = fecmodif;
        this.usuarioId = usuarioId;
    }

    

    public Integer getPtovtaAntecipaComissaoId() {
		return ptovtaAntecipaComissaoId;
	}

	public void setPtovtaAntecipaComissaoId(Integer ptovtaAntecipaComissaoId) {
		this.ptovtaAntecipaComissaoId = ptovtaAntecipaComissaoId;
	}

	public Date getData() {
        return data;
    }

    public void setData(Date data) {
        this.data = data;
    }

    public BigDecimal getRetem() {
        return retem;
    }

    public void setRetem(BigDecimal retem) {
        this.retem = retem;
    }

    public BigDecimal getPercentual() {
        return percentual;
    }

    public void setPercentual(BigDecimal percentual) {
        this.percentual = percentual;
    }

    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 int getUsuarioId() {
        return usuarioId;
    }

    public void setUsuarioId(int usuarioId) {
        this.usuarioId = usuarioId;
    }

    public PuntoVenta getPuntoventaId() {
        return puntoventaId;
    }

    public void setPuntoventaId(PuntoVenta puntoventaId) {
        this.puntoventaId = puntoventaId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (ptovtaAntecipaComissaoId != null ? ptovtaAntecipaComissaoId.hashCode() : 0);
        return hash;
    }
    
	@Override
	public void clonar() throws CloneNotSupportedException {
		
		ptovtaAntecipacomissaoClone = new PtovtaAntecipacomissao();
		ptovtaAntecipacomissaoClone = (PtovtaAntecipacomissao) this.clone();
		Hibernate.initialize(ptovtaAntecipacomissaoClone.getPuntoventaId());
	}
	
	@Override
	public PtovtaAntecipacomissao getCloneObject() throws CloneNotSupportedException {
		return ptovtaAntecipacomissaoClone;
	}

	@Override
	public String getTextoInclusaoExclusao() {
		return String.format("ID [%s]", getPtovtaAntecipaComissaoId());
	}

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof PtovtaAntecipacomissao)) {
            return false;
        }
        PtovtaAntecipacomissao other = (PtovtaAntecipacomissao) object;
        if ((this.ptovtaAntecipaComissaoId == null && other.ptovtaAntecipaComissaoId != null) || (this.ptovtaAntecipaComissaoId != null && !this.ptovtaAntecipaComissaoId.equals(other.ptovtaAntecipaComissaoId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.rjconsultores.ventaboletos.entidad.PtovtaAntecipacomissao[ ptovtaAntecipaComissaoId=" + ptovtaAntecipaComissaoId + " ]";
    }
    
}
