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;

/**
*
* @author daniel.zauli
*/
@Entity
@SequenceGenerator(name = "TARIFA_KM_SEQ", sequenceName = "TARIFA_KM_SEQ", allocationSize = 1)
@Table(name = "TARIFA_KM")
public class TarifaKm implements Serializable, Comparable<TarifaKm>{ 
	
	private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @GeneratedValue(strategy = GenerationType.AUTO, generator = "TARIFA_KM_SEQ")
    @Column(name = "TARIFAKM_ID")
    private Integer tarifakmId;
    
    @JoinColumn(name = "ORGAOCONCEDENTE_ID", referencedColumnName = "ORGAOCONCEDENTE_ID")
    @ManyToOne
    private OrgaoConcedente orgaoconcedenteId;
    
    @Column(name = "KMATE")
    private BigDecimal kmate;
    
 // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "VALORTAXA")  // tarifa 
    private BigDecimal valortaxa;
    
    @JoinColumn(name = "CLASESERVICIO_ID", referencedColumnName = "CLASESERVICIO_ID")
    @ManyToOne
    private ClaseServicio claseServicio;
    
    @Column(name = "ACTIVO")
    private Boolean activo;
    
    @Column(name = "FECMODIF")
    @Temporal(TemporalType.TIMESTAMP)
    private Date fecmodif;
    
    @Column(name = "USUARIO_ID")
    private Integer usuarioId;
    
    public TarifaKm(){}
    
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (tarifakmId != null ? tarifakmId.hashCode() : 0);
        return hash;
    }

    @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 TarifaKm)) {
            return false;
        }
        TarifaKm other = (TarifaKm) object;
        if ((this.tarifakmId == null && other.tarifakmId != null) || (this.tarifakmId != null && !this.tarifakmId.equals(other.tarifakmId))) {
            return false;
        }
        return true;
    }

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

	public Integer getTarifakmId() {
		return tarifakmId;
	}

	public void setTarifakmId(Integer tarifakmId) {
		this.tarifakmId = tarifakmId;
	}

	public OrgaoConcedente getOrgaoconcedenteId() {
		return orgaoconcedenteId;
	}

	public void setOrgaoconcedenteId(OrgaoConcedente orgaoconcedenteId) {
		this.orgaoconcedenteId = orgaoconcedenteId;
	}

	public BigDecimal getKmate() {
		return kmate;
	}

	public void setKmate(BigDecimal kmate) {
		this.kmate = kmate;
	}

	public BigDecimal getValortaxa() {
		return valortaxa;
	}

	public void setValortaxa(BigDecimal valortaxa) {
		this.valortaxa = valortaxa;
	}

	public ClaseServicio getClaseServicio() {
		return claseServicio;
	}

	public void setClaseServicio(ClaseServicio claseServicio) {
		this.claseServicio = claseServicio;
	}

	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;
	}
	
	@Override
	public int compareTo(TarifaKm tkm) {
		return this.getKmate().intValue() -     tkm.getKmate().intValue();
	}
    
}
