package com.rjconsultores.ventaboletos.entidad;

import java.io.Serializable;
import java.math.BigDecimal;
import java.text.NumberFormat;
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.SequenceGenerator;
import javax.persistence.Table;

@Entity
@SequenceGenerator(name = "ITEM_DESCONTO_SEQ", sequenceName = "ITEM_DESCONTO_SEQ", allocationSize = 1)
@Table(name = "ITEM_DESCONTO")
public class ItemDesconto implements Serializable {

	private static final long serialVersionUID = 1L;
	
	private static NumberFormat NF = NumberFormat.getInstance();

	@Id
    @Basic(optional = false)
    @GeneratedValue(strategy = GenerationType.AUTO, generator = "ITEM_DESCONTO_SEQ")
    @Column(name = "ITEMDESCONTO_ID")
	private Long itemdescontoId;
	
	@Column(name = "NOMITEMDESCONTO")
	private String nomitemdesconto;

	@Column(name = "PRECO")
	private BigDecimal preco;

	@Column(name = "ACTIVO")
	private boolean activo;

	@Column(name = "FECMODIF")
	private Date fecmodif;
	
	@Column(name = "USUARIO_ID")
	private Integer usuarioId;

	public Long getItemdescontoId() {
		return itemdescontoId;
	}

	public void setItemdescontoId(Long itemdescontoId) {
		this.itemdescontoId = itemdescontoId;
	}

	public String getNomitemdesconto() {
		return nomitemdesconto;
	}

	public void setNomitemdesconto(String nomitemdesconto) {
		this.nomitemdesconto = nomitemdesconto;
	}

	public BigDecimal getPreco() {
		return preco;
	}

	public void setPreco(BigDecimal preco) {
		this.preco = preco;
	}

	public boolean isActivo() {
		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 String toString() {
		NF.setMinimumFractionDigits(2);
		return this.getNomitemdesconto() + " - " + NF.format(this.getPreco());
	}

}
