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;

/**
 * @author Bruno Rodrigo
 *
 */
@Entity
@SequenceGenerator(name = "GP_PRICING_ESP_CANAL_SEQ", sequenceName = "GP_PRICING_ESP_CANAL_SEQ", allocationSize = 1)
@Table(name = "GP_PRICING_ESP_CANAL_VENTA")
public class GP_PricingEspecificoCanalVendas implements Serializable, Cloneable {

	private static final long serialVersionUID = 1L;
	@Id
	@Basic(optional = false)
	@GeneratedValue(strategy = GenerationType.AUTO, generator = "GP_PRICING_ESP_CANAL_SEQ")
	@Column(name = "PRICINGESPCANAL_ID")
	private Integer pricingEspecificoCanalId;
	
	@ManyToOne
	@JoinColumn(name = "TIPOPTOVTA_ID", referencedColumnName = "TIPOPTOVTA_ID")
	private TipoPuntoVenta tipoPtovta;
	
	@Basic(optional = false)
	@Column(name = "ACTIVO")
	private Boolean activo;

	@Column(name = "FECMODIF")
	@Temporal(TemporalType.TIMESTAMP)
	private Date fecmodif;
	@Basic(optional = false)
	@Column(name = "USUARIO_ID")
	private Integer usuarioId;
    @JoinColumn(name = "PRICINGESPECIFICO_ID", referencedColumnName = "PRICINGESPECIFICO_ID")
	@ManyToOne
	private GP_PricingEspecifico pricingEspecifico;
    
	public GP_PricingEspecificoCanalVendas() {
		super();
	}
	public GP_PricingEspecificoCanalVendas(TipoPuntoVenta tipoPtovta, GP_PricingEspecifico pricingEspecifico, Integer usuarioId) {
		super();
		
		this.tipoPtovta = tipoPtovta;
		this.pricingEspecifico = pricingEspecifico;
		this.usuarioId  = usuarioId;
		this.fecmodif = new Date();
		this.activo = Boolean.TRUE;
	}
	
	public Integer getPricingEspecificoCanalId() {
		return pricingEspecificoCanalId;
	}
	public void setPricingEspecificoCanalId(Integer pricingEspecificoCanalId) {
		this.pricingEspecificoCanalId = pricingEspecificoCanalId;
	}
	public TipoPuntoVenta getTipoPtovta() {
		return tipoPtovta;
	}
	public void setTipoPtovta(TipoPuntoVenta tipoPtovta) {
		this.tipoPtovta = tipoPtovta;
	}
	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 GP_PricingEspecifico getPricingEspecifico() {
		return pricingEspecifico;
	}
	public void setPricingEspecifico(GP_PricingEspecifico pricingEspecifico) {
		this.pricingEspecifico = pricingEspecifico;
	}
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((activo == null) ? 0 : activo.hashCode());
		result = prime * result + ((pricingEspecifico == null) ? 0 : pricingEspecifico.hashCode());
		result = prime * result + ((tipoPtovta == null) ? 0 : tipoPtovta.hashCode());
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		GP_PricingEspecificoCanalVendas other = (GP_PricingEspecificoCanalVendas) obj;
		if (activo == null) {
			if (other.activo != null)
				return false;
		} else if (!activo.equals(other.activo))
			return false;
		if (pricingEspecifico == null) {
			if (other.pricingEspecifico != null)
				return false;
		} else if (!pricingEspecifico.equals(other.pricingEspecifico))
			return false;
		if (tipoPtovta == null) {
			if (other.tipoPtovta != null)
				return false;
		} else if (!tipoPtovta.equals(other.tipoPtovta))
			return false;
		return true;
	}

	
	
	@Override
	public String toString() {
		return " [TIPO_PONTO_VENDA=" + tipoPtovta.toString() + "]";
	}
	@Override
	protected Object clone() throws CloneNotSupportedException {
		return super.clone();
	}
}
