/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.cosmodas.EntCosmos;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.Lob;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 * @author depv
 */
@Entity
@Table(name = "abonofl")
@XmlRootElement
@NamedQueries({
        @NamedQuery(name = "Abonofl.findAll", query = "SELECT a FROM Abonofl a"),
        @NamedQuery(name = "Abonofl.findByTipo", query = "SELECT a FROM Abonofl a WHERE a.abonoflPK.tipo = :tipo"),
        @NamedQuery(name = "Abonofl.findByTipoAndVerificada", query = "SELECT a FROM Abonofl a WHERE a.abonoflPK.tipo = :tipo AND a.verificado = false"),
        @NamedQuery(name = "Abonofl.findByCabono", query = "SELECT a FROM Abonofl a WHERE a.abonoflPK.cabono = :cabono"),
        @NamedQuery(name = "Abonofl.findByConsultorCodigo", query = "SELECT a FROM Abonofl a WHERE a.consultorCodigo = :consultorCodigo"),
        @NamedQuery(name = "Abonofl.findByFecha", query = "SELECT a FROM Abonofl a WHERE a.fecha = :fecha"),
        @NamedQuery(name = "Abonofl.findByMonto", query = "SELECT a FROM Abonofl a WHERE a.monto = :monto"),
        @NamedQuery(name = "Abonofl.findByFechaPago", query = "SELECT a FROM Abonofl a WHERE a.fechaPago = :fechaPago"),
        @NamedQuery(name = "Abonofl.findByBanco", query = "SELECT a FROM Abonofl a WHERE a.banco = :banco"),
        @NamedQuery(name = "Abonofl.findByVerificado", query = "SELECT a FROM Abonofl a WHERE a.verificado = :verificado"),
        @NamedQuery(name = "Abonofl.findByNumeroRecibo", query = "SELECT a FROM Abonofl a WHERE a.numeroRecibo = :numeroRecibo"),
        @NamedQuery(name = "Abonofl.findByUsuarioAplica", query = "SELECT a FROM Abonofl a WHERE a.usuarioAplica = :usuarioAplica"),
        @NamedQuery(name = "Abonofl.findByUsuarioIngresa", query = "SELECT a FROM Abonofl a WHERE a.usuarioIngresa = :usuarioIngresa and a.aplicado = :aplicado"),
        @NamedQuery(name = "Abonofl.findByUsuarioAnula", query = "SELECT a FROM Abonofl a WHERE a.usuarioIngresa = :usuarioIngresa and a.anulado = :anulado"),
        @NamedQuery(name = "Abonofl.allbyUser", query = "SELECT a FROM Abonofl a WHERE a.usuarioIngresa = :usuarioIngresa"),
        @NamedQuery(name = "Abonofl.noprocesadas", query = "SELECT a FROM Abonofl a WHERE a.anulado = false and a.aplicado = :aplicado and a.abonoflPK.tipo = :tipo and a.fecha = :fecha"),
        @NamedQuery(name = "Abonofl.noprocesadaSinFecha", query = "SELECT a FROM Abonofl a WHERE a.anulado = false and a.aplicado = :aplicado and a.abonoflPK.tipo = :tipo"),
        @NamedQuery(name = "Abonofl.anuladas", query = "SELECT a FROM Abonofl a WHERE a.anulado = true and a.abonoflPK.tipo = :tipo and a.fecha = :fecha"),
        @NamedQuery(name = "Abonofl.todasPorFecha", query = "SELECT a FROM Abonofl a WHERE a.abonoflPK.tipo = :tipo and a.fecha = :fecha"),
        @NamedQuery(name = "Abonofl.AnulaBoleta", query = "UPDATE Abonofl a SET a.anulado = :anulado, a.comentarios = :comentarios WHERE a.abonoflPK.tipo = :tipo AND a.abonoflPK.cabono = :cabono")})
public class Abonofl implements Serializable {

    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected AbonoflPK abonoflPK;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 6)
    @Column(name = "consultor_codigo")
    private String consultorCodigo;
    @Basic(optional = false)
    @NotNull
    @Column(name = "fecha")
    @Temporal(TemporalType.DATE)
    private Date fecha;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Basic(optional = false)
    @NotNull
    @Column(name = "monto")
    private BigDecimal monto;
    @Basic(optional = false)
    @NotNull
    @Column(name = "fecha_pago")
    @Temporal(TemporalType.DATE)
    private Date fechaPago;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 2)
    @Column(name = "banco")
    private String banco;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 1)
    @Column(name = "verificado")
    private boolean verificado;
    @Size(max = 6)
    @Column(name = "numero_recibo")
    private String numeroRecibo;
    @Lob
    @Size(max = 65535)
    @Column(name = "comentarios")
    private String comentarios;
    @Size(max = 3)
    @Column(name = "usuario_ingresa")
    private String usuarioIngresa;
    @Size(max = 3)
    @Column(name = "usuario_aplica")
    private String usuarioAplica;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 1)
    @Column(name = "anulado")
    private boolean anulado;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 1)
    @Column(name = "aplicado")
    private boolean aplicado;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 1)
    @Column(name = "impreso")
    private boolean impreso;

    public Abonofl() {
    }

    public Abonofl(AbonoflPK abonoflPK) {
        this.abonoflPK = abonoflPK;
    }

    public Abonofl(AbonoflPK abonoflPK, String consultorCodigo, Date fecha, BigDecimal monto, Date fechaPago, String banco, boolean verificado, String numeroRecibo, String comentarios, String usuarioIngresa, String usuarioAplica, boolean anulado, boolean aplicado, boolean impreso) {
        this.abonoflPK = abonoflPK;
        this.consultorCodigo = consultorCodigo;
        this.fecha = fecha;
        this.monto = monto;
        this.fechaPago = fechaPago;
        this.banco = banco;
        this.verificado = verificado;
        this.numeroRecibo = numeroRecibo;
        this.comentarios = comentarios;
        this.usuarioIngresa = usuarioIngresa;
        this.usuarioAplica = usuarioAplica;
        this.anulado = anulado;
        this.aplicado = aplicado;
        this.impreso = impreso;
    }

    public boolean isImpreso() {
        return impreso;
    }

    public void setImpreso(boolean impreso) {
        this.impreso = impreso;
    }

    public boolean isAplicado() {
        return aplicado;
    }

    public void setAplicado(boolean aplicado) {
        this.aplicado = aplicado;
    }

    public boolean isAnulado() {
        return anulado;
    }

    public void setAnulado(boolean anulado) {
        this.anulado = anulado;
    }


    public Abonofl(String tipo, String cabono) {
        this.abonoflPK = new AbonoflPK(tipo, cabono);
    }

    public AbonoflPK getAbonoflPK() {
        return abonoflPK;
    }

    public void setAbonoflPK(AbonoflPK abonoflPK) {
        this.abonoflPK = abonoflPK;
    }

    public String getConsultorCodigo() {
        return consultorCodigo;
    }

    public void setConsultorCodigo(String consultorCodigo) {
        this.consultorCodigo = consultorCodigo;
    }

    public Date getFecha() {
        return fecha;
    }

    public void setFecha(Date fecha) {
        this.fecha = fecha;
    }

    public BigDecimal getMonto() {
        return monto;
    }

    public void setMonto(BigDecimal monto) {
        this.monto = monto;
    }

    public Date getFechaPago() {
        return fechaPago;
    }

    public void setFechaPago(Date fechaPago) {
        this.fechaPago = fechaPago;
    }

    public String getBanco() {
        return banco;
    }

    public void setBanco(String banco) {
        this.banco = banco;
    }

    public boolean getVerificado() {
        return verificado;
    }

    public void setVerificado(boolean verificado) {
        this.verificado = verificado;
    }

    public String getNumeroRecibo() {
        return numeroRecibo;
    }

    public void setNumeroRecibo(String numeroRecibo) {
        this.numeroRecibo = numeroRecibo;
    }

    public String getComentarios() {
        return comentarios;
    }

    public void setComentarios(String comentarios) {
        this.comentarios = comentarios;
    }

    public String getUsuarioIngresa() {
        return usuarioIngresa;
    }

    public void setUsuarioIngresa(String usuarioIngresa) {
        this.usuarioIngresa = usuarioIngresa;
    }

    public String getUsuarioAplica() {
        return usuarioAplica;
    }

    public void setUsuarioAplica(String usuarioAplica) {
        this.usuarioAplica = usuarioAplica;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (abonoflPK != null ? abonoflPK.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 Abonofl)) {
            return false;
        }
        Abonofl other = (Abonofl) object;
        if ((this.abonoflPK == null && other.abonoflPK != null) || (this.abonoflPK != null && !this.abonoflPK.equals(other.abonoflPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.cosmodas.EntCosmos.Abonofl[ abonoflPK=" + abonoflPK + " ]";
    }

}
