/*
 * 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.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;
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;
import javax.persistence.TemporalType;

import org.apache.commons.lang.BooleanUtils;

/**
 * 
 * @author Rafius
 */
@Entity
@SequenceGenerator(name = "PRICING_SEQ", sequenceName = "PRICING_SEQ", allocationSize = 1)
@Table(name = "PRICING")
public class Pricing implements Serializable {

	private static final long serialVersionUID = 1L;
	public static final Integer ATIVO = 1;
	public static final Integer INATIVO = 2;
	public static final Integer EXCLUIDO = 0;
	@Id
	@Basic(optional = false)
	@GeneratedValue(strategy = GenerationType.AUTO, generator = "PRICING_SEQ")
	@Column(name = "PRICING_ID")
	private Integer pricingId;
	@Column(name = "NOMBPRICING")
	private String nombPricing;
	@Column(name = "CANTBOLETO")
	private Short cantboleto;
	// Rafael - Campo retirado pela Leticia no dia 15/02/2011.
	// @Column(name = "DESCUENTOIMPORTE")
	// private BigDecimal descuentoimporte;
	@Column(name = "DESCUENTOPORCENTAJE")
	private BigDecimal descuentoporcentaje;
	@Column(name = "DESCUENTOPORCREDONDO")
	private BigDecimal descuentoporcredondo;
	@Column(name = "INDTRANSFERIBLE")
	private Boolean indtransferible;
	@Column(name = "INDRESERVABLE")
	private Boolean indreservable;
	@Column(name = "EXIBEVENDA")
	private Boolean exibeVenda;
	@Column(name = "INDCANCELABLE")
	private Boolean indcancelable;
	@Column(name = "ACTIVO")
	private Integer activo;
	@Column(name = "FECMODIF")
	@Temporal(TemporalType.TIMESTAMP)
	private Date fecmodif;
	@Column(name = "USUARIO_ID")
	private Integer usuarioId;
	@Column(name = "CANTDIASANTICIPACION")
	private Integer cantdiasanticipacion;
	@OneToMany(mappedBy = "pricing", cascade = CascadeType.ALL)
	private List<PricingAsiento> pricingAsientoList;
	@OneToMany(mappedBy = "pricing", cascade = CascadeType.ALL)
	private List<PricingMercado> pricingMercadoList;
	@OneToMany(mappedBy = "pricing", cascade = CascadeType.ALL)
	private List<PricingMarca> pricingMarcaList;
	@JoinColumn(name = "EMPRESA_ID", referencedColumnName = "EMPRESA_ID")
	@ManyToOne
	private Empresa empresa;
	@OneToMany(mappedBy = "pricing", cascade = CascadeType.ALL)
	private List<PricingRuta> pricingRutaList;
	@OneToMany(mappedBy = "pricing", cascade = CascadeType.ALL)
	private List<PricingDia> pricingDiaList;
	@OneToMany(mappedBy = "pricing", cascade = CascadeType.ALL)
	private List<PricingImporte> pricingImporteList;
	@OneToMany(mappedBy = "pricing", cascade = CascadeType.ALL)
	private List<PricingTipoPtoVta> pricingTipoptovtaList;
	@OneToMany(mappedBy = "pricing", cascade = CascadeType.ALL)
	private List<PricingCategoria> pricingCategoriaList;
	@OneToMany(mappedBy = "pricing", cascade = CascadeType.ALL)
	private List<PricingVigencia> pricingVigenciaList;
	@OneToMany(mappedBy = "pricing", cascade = CascadeType.ALL)
	private List<PricingClase> pricingClaseList;
	@OneToMany(mappedBy = "pricing", cascade = CascadeType.ALL)
	private List<PricingCorrida> pricingCorridaList;
	@OneToMany(mappedBy = "pricing", cascade = CascadeType.ALL)
	private List<PricingPuntoVenta> pricingPuntoventaList;
	@OneToMany(mappedBy = "pricing", cascade = CascadeType.ALL)
	private List<PricingTipoServicio> pricingTipoServicioList;
	@OneToMany(mappedBy = "pricing", cascade = CascadeType.ALL)
	private List<PricingOcupaAntecipa> pricingOcupaAntecipaList;
	@OneToMany(mappedBy = "pricing", cascade = CascadeType.ALL)
	private List<PricingFormapago> pricingFormapagoList;
	@Column(name = "INDGENERAFERIADOVIAJE")
	private String indGeneraFeriadoViaje;
	@Column(name = "INDGENERAFERIADOVENTA")
	private String indGeneraFeriadoVenta;
	
	@Column(name = "INDOCUPACAOPORTRECHO")
	private Boolean indOcupacaoPorTrecho;
	
	@Column(name = "INDSOMENTEASSENTOSUGERIDO")
	private Boolean indSomenteAssentoSugerido;
	
	@Column(name = "INDPRICINGDIVIDIRIDAEVOLTA")
	private Boolean indPricingDividirIdaEVolta;
	
	@Column(name = "INDSAFER")
	private Boolean indSafer;
	
	@Column(name = "INDEXIBEPOPUPPRICINGPOL")
	private Boolean indExibePopupPricingPol;
	
	@OneToMany(mappedBy = "pricing", cascade = CascadeType.ALL)
	private List<PricingConexao> pricingConexaoList;

	public enum GerarFeriado {
		// Declaracao dos enum
		GERARSEMPRE("GERAR SEMPRE", "S"),

		GERARQUANDOFERIADO("GERAR SÓ QUANDO FOR FERIADO", "F"),

		GERARQUANDONAOFERIADO("GERAR QUANDO NÃO FOR FERIADO", "N");

		// Definicao das constantes
		public final String valor;
		public final String descricao;

		public String valor() {
			return this.valor;
		}

		public String descricao() {
			return this.descricao;
		}

		private GerarFeriado(String descricao, String valor) {
			this.descricao = descricao;
			this.valor = valor;
		}
	}

	public Pricing() {
	}

	public Pricing(Integer pricingId) {
		this.pricingId = pricingId;
	}

	public Integer getPricingId() {
		return pricingId;
	}

	public void setPricingId(Integer pricingId) {
		this.pricingId = pricingId;
	}

	public Short getCantboleto() {
		return cantboleto;
	}

	public Integer getCantdiasanticipacion() {
		return cantdiasanticipacion;
	}

	public void setCantdiasanticipacion(Integer cantdiasanticipacion) {
		this.cantdiasanticipacion = cantdiasanticipacion;
	}

	public void setCantboleto(Short cantboleto) {
		this.cantboleto = cantboleto;
	}

	public BigDecimal getDescuentoporcentaje() {
		return descuentoporcentaje;
	}

	public void setDescuentoporcentaje(BigDecimal descuentoporcentaje) {
		this.descuentoporcentaje = descuentoporcentaje;
	}

	public BigDecimal getDescuentoporcredondo() {
		return descuentoporcredondo;
	}

	public void setDescuentoporcredondo(BigDecimal descuentoporcredondo) {
		this.descuentoporcredondo = descuentoporcredondo;
	}

	public Boolean getIndtransferible() {
		return BooleanUtils.toBoolean(indtransferible);
	}

	public void setIndtransferible(Boolean indtransferible) {
		this.indtransferible = indtransferible;
	}

	public Boolean getIndreservable() {
		return BooleanUtils.toBoolean(indreservable);
	}

	public void setIndreservable(Boolean indreservable) {
		this.indreservable = indreservable;
	}

	public Boolean getIndcancelable() {
		return BooleanUtils.toBoolean(indcancelable);
	}

	public void setIndcancelable(Boolean indcancelable) {
		this.indcancelable = indcancelable;
	}

	public Integer getActivo() {
		return activo;
	}

	public void setActivo(Integer 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 List<PricingOcupaAntecipa> getPricingOcupaAntecipaList() {
		List<PricingOcupaAntecipa> poaList = new ArrayList<PricingOcupaAntecipa>();
		for (PricingOcupaAntecipa poa : this.pricingOcupaAntecipaList) {
			if (poa.getActivo() != EXCLUIDO.intValue()) {
				poaList.add(poa);
			}
		}
		return poaList;
	}

	public void setPricingOcupaAntecipaList(List<PricingOcupaAntecipa> pricingOcupaAntecipaList) {
		this.pricingOcupaAntecipaList = pricingOcupaAntecipaList;
	}

	public List<PricingAsiento> getPricingAsientoList() {
		List<PricingAsiento> paList = new ArrayList<PricingAsiento>();
		for (PricingAsiento pa : this.pricingAsientoList) {
			if (pa.getActivo() != EXCLUIDO.intValue()) {
				paList.add(pa);
			}
		}

		return paList;
	}

	public void setPricingAsientoList(List<PricingAsiento> pricingAsientoList) {
		this.pricingAsientoList = pricingAsientoList;
	}

	public List<PricingMercado> getPricingMercadoList() {
		List<PricingMercado> pmList = new ArrayList<PricingMercado>();
		for (PricingMercado pm : this.pricingMercadoList) {
			if (pm.getActivo() != EXCLUIDO.intValue()) {
				pmList.add(pm);
			}
		}

		return pmList;
	}

	public void setPricingMercadoList(List<PricingMercado> pricingMercadoList) {
		this.pricingMercadoList = pricingMercadoList;
	}

	public List<PricingMarca> getPricingMarcaList() {
		List<PricingMarca> pmList = new ArrayList<PricingMarca>();
		for (PricingMarca pm : this.pricingMarcaList) {
			if (pm.getActivo() != EXCLUIDO.intValue()) {
				pmList.add(pm);
			}
		}

		return pmList;
	}

	public void setPricingMarcaList(List<PricingMarca> pricingMarcaList) {
		this.pricingMarcaList = pricingMarcaList;
	}

	public Empresa getEmpresa() {
		return empresa;
	}

	public void setEmpresa(Empresa empresa) {
		this.empresa = empresa;
	}

	public List<PricingRuta> getPricingRutaList() {
		List<PricingRuta> prList = new ArrayList<PricingRuta>();
		for (PricingRuta pr : this.pricingRutaList) {
			if (pr.getActivo() != EXCLUIDO.intValue()) {
				prList.add(pr);
			}
		}

		return prList;
	}

	public void setPricingRutaList(List<PricingRuta> pricingRutaList) {
		this.pricingRutaList = pricingRutaList;
	}

	public List<PricingDia> getPricingDiaList() {
		List<PricingDia> pdList = new ArrayList<PricingDia>();
		for (PricingDia pd : this.pricingDiaList) {
			if (pd.getActivo() != EXCLUIDO.intValue()) {
				pdList.add(pd);
			}
		}

		return pdList;
	}

	public void setPricingDiaList(List<PricingDia> pricingDiaList) {
		this.pricingDiaList = pricingDiaList;
	}

	public List<PricingImporte> getPricingImporteList() {
		List<PricingImporte> piList = new ArrayList<PricingImporte>();
		for (PricingImporte pi : this.pricingImporteList) {
			if (pi.getActivo() != EXCLUIDO.intValue()) {
				piList.add(pi);
			}
		}

		return piList;
	}

	public void setPricingImporteList(List<PricingImporte> pricingImporteList) {
		this.pricingImporteList = pricingImporteList;
	}

	public List<PricingTipoPtoVta> getPricingTipoptovtaList() {
		List<PricingTipoPtoVta> ptList = new ArrayList<PricingTipoPtoVta>();
		for (PricingTipoPtoVta pt : this.pricingTipoptovtaList) {
			if (pt.getActivo() != EXCLUIDO.intValue()) {
				ptList.add(pt);
			}
		}

		return ptList;
	}

	public void setPricingTipoptovtaList(List<PricingTipoPtoVta> pricingTipoptovtaList) {
		this.pricingTipoptovtaList = pricingTipoptovtaList;
	}

	public List<PricingCategoria> getPricingCategoriaList() {
		List<PricingCategoria> pcList = new ArrayList<PricingCategoria>();
		for (PricingCategoria pc : this.pricingCategoriaList) {
			if (pc.getActivo() != EXCLUIDO.intValue()) {
				pcList.add(pc);
			}
		}

		return pcList;
	}

	public void setPricingCategoriaList(List<PricingCategoria> pricingCategoriaList) {
		this.pricingCategoriaList = pricingCategoriaList;
	}

	public List<PricingVigencia> getPricingVigenciaList() {
		List<PricingVigencia> pvList = new ArrayList<PricingVigencia>();
		if (this.pricingVigenciaList != null) {
			for (PricingVigencia pv : this.pricingVigenciaList) {
				if (pv.getActivo() != EXCLUIDO.intValue()) {
					pvList.add(pv);
				}
			}
		}

		return pvList;
	}

	public void setPricingVigenciaList(List<PricingVigencia> pricingVigenciaList) {
		this.pricingVigenciaList = pricingVigenciaList;
	}

	public List<PricingClase> getPricingClaseList() {
		List<PricingClase> pcList = new ArrayList<PricingClase>();
		for (PricingClase pc : this.pricingClaseList) {
			if (pc.getActivo() != EXCLUIDO.intValue()) {
				pcList.add(pc);
			}
		}

		return pcList;
	}

	public void setPricingClaseList(List<PricingClase> pricingClaseList) {
		this.pricingClaseList = pricingClaseList;
	}

	public List<PricingCorrida> getPricingCorridaList() {
		List<PricingCorrida> pcList = new ArrayList<PricingCorrida>();
		if (pricingCorridaList == null) {
			return null;
		}

		for (PricingCorrida pc : this.pricingCorridaList) {
			if (pc.getActivo() != EXCLUIDO.intValue()) {
				pcList.add(pc);
			}
		}

		return pcList;
	}

	public void setPricingCorridaList(List<PricingCorrida> pricingCorridaList) {
		this.pricingCorridaList = pricingCorridaList;
	}

	public List<PricingPuntoVenta> getPricingPuntoventaList() {
		List<PricingPuntoVenta> ppList = new ArrayList<PricingPuntoVenta>();
		for (PricingPuntoVenta pp : this.pricingPuntoventaList) {
			if (pp.getActivo() != EXCLUIDO.intValue()) {
				ppList.add(pp);
			}
		}

		return ppList;
	}

	public void setPricingPuntoventaList(List<PricingPuntoVenta> pricingPuntoventaList) {
		this.pricingPuntoventaList = pricingPuntoventaList;
	}

	public List<PricingTipoServicio> getPricingTipoServicioList() {
		List<PricingTipoServicio> ppList = new ArrayList<PricingTipoServicio>();
		for (PricingTipoServicio pp : this.pricingTipoServicioList) {
			if (pp.getActivo() != EXCLUIDO.intValue()) {
				ppList.add(pp);
			}
		}

		return ppList;
	}

	public void setPricingTipoServicioList(List<PricingTipoServicio> pricingTipoServicioList) {
		this.pricingTipoServicioList = pricingTipoServicioList;
	}

	public List<PricingFormapago> getPricingFormapagoList() {

		List<PricingFormapago> pfpList = new ArrayList<PricingFormapago>();
		for (PricingFormapago pfp : this.pricingFormapagoList) {
			if (pfp.getActivo() != EXCLUIDO.intValue()) {
				pfpList.add(pfp);
			}
		}

		return pfpList;
	}

	public void setPricingFormapagoList(List<PricingFormapago> pricingFormapagoList) {
		this.pricingFormapagoList = pricingFormapagoList;
	}

	public String getIndGeneraFeriadoViaje() {
		return indGeneraFeriadoViaje;
	}

	public void setIndGeneraFeriadoViaje(String indGeneraFeriadoViaje) {
		this.indGeneraFeriadoViaje = indGeneraFeriadoViaje;
	}

	public String getIndGeneraFeriadoVenta() {
		return indGeneraFeriadoVenta;
	}

	public void setIndGeneraFeriadoVenta(String indGeneraFeriadoVenta) {
		this.indGeneraFeriadoVenta = indGeneraFeriadoVenta;
	}

	public String getNombPricing() {
		return nombPricing;
	}

	public void setNombPricing(String nombPricing) {
		this.nombPricing = nombPricing;
	}
	
	public Boolean getExibeVenda() {
		return BooleanUtils.toBoolean(exibeVenda);
	}

	public void setExibeVenda(Boolean exibeVenda) {
		this.exibeVenda = exibeVenda;
	}

	@Override
	public int hashCode() {
		int hash = 0;
		hash += (pricingId != null ? pricingId.hashCode() : 0);
		return hash;
	}

	@Override
	public boolean equals(Object object) {
		if (!(object instanceof Pricing)) {
			return false;
		}
		Pricing other = (Pricing) object;
		if ((this.pricingId == null && other.pricingId != null) || (this.pricingId != null && !this.pricingId.equals(other.pricingId))) {
			return false;
		}
		return true;
	}

	@Override
	public String toString() {
		return "entidad.test.Pricing[pricingId=" + pricingId + "]";
	}

	public Boolean getIndOcupacaoPorTrecho() {
		return BooleanUtils.toBoolean(indOcupacaoPorTrecho);
	}

	public void setIndOcupacaoPorTrecho(Boolean indOcupacaoPorTrecho) {
		this.indOcupacaoPorTrecho = indOcupacaoPorTrecho;
	}

	public Boolean getIndSomenteAssentoSugerido() {
		return BooleanUtils.toBoolean(indSomenteAssentoSugerido);
	}

	public void setIndSomenteAssentoSugerido(Boolean indSomenteAssentoSugerido) {
		this.indSomenteAssentoSugerido = indSomenteAssentoSugerido;
	}

	public Boolean getIndPricingDividirIdaEVolta() {
		return BooleanUtils.toBoolean(indPricingDividirIdaEVolta);
	}

	public void setIndPricingDividirIdaEVolta(Boolean indPricingDividirIdaEVolta) {
		this.indPricingDividirIdaEVolta = indPricingDividirIdaEVolta;
	}

	public Boolean getIndSafer() {
		return indSafer;
	}

	public void setIndSafer(Boolean indSafer) {
		this.indSafer = indSafer;
	}

	public List<PricingConexao> getPricingConexaoList() {
		
		if(pricingConexaoList == null) {
			pricingConexaoList = new ArrayList<>();
		}
		
		List<PricingConexao> pConexaoList = new ArrayList<PricingConexao>();
		for (PricingConexao pCp : this.pricingConexaoList) {
			if (pCp.getActivo() != EXCLUIDO.intValue()) {
				pConexaoList.add(pCp);
			}
		}

		return pConexaoList;
	}

	public void setPricingConexaoList(List<PricingConexao> pricingConexaoList) {
		this.pricingConexaoList = pricingConexaoList;
	}

	public Boolean getIndExibePopupPricingPol() {
		return indExibePopupPricingPol!=null ? indExibePopupPricingPol : Boolean.FALSE;
	}

	public void setIndExibePopupPricingPol(Boolean indExibePopupPricingPol) {
		this.indExibePopupPricingPol = indExibePopupPricingPol;
	}
	
	
}
