/*
 * 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.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
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 obper
 */
@Entity
@Table(name = "detalle_abonos")
@XmlRootElement
@NamedQueries({
        @NamedQuery(name = "DetalleAbonos.findAll", query = "SELECT d FROM DetalleAbonos d"),
        @NamedQuery(name = "DetalleAbonos.findByAbonoAnulado", query = "SELECT d FROM DetalleAbonos d WHERE d.detalleAbonosPK.abonoAnulado = :abonoAnulado"),
        @NamedQuery(name = "DetalleAbonos.findByAbonoCodigo", query = "SELECT d FROM DetalleAbonos d WHERE d.detalleAbonosPK.abonoCodigo = :abonoCodigo"),
        @NamedQuery(name = "DetalleAbonos.findByAbonoCodigoAndAbonoTipo", query = "SELECT d FROM DetalleAbonos d WHERE d.detalleAbonosPK.abonoCodigo = :abonoCodigo AND d.detalleAbonosPK.abonoTipo = :abonoTipo"),
        @NamedQuery(name = "DetalleAbonos.findByAbonoTipo", query = "SELECT d FROM DetalleAbonos d WHERE d.detalleAbonosPK.abonoTipo = :abonoTipo"),
        @NamedQuery(name = "DetalleAbonos.findByFacturaCodigo", query = "SELECT d FROM DetalleAbonos d WHERE d.detalleAbonosPK.facturaCodigo = :facturaCodigo"),
        @NamedQuery(name = "DetalleAbonos.findByFacturaSerie", query = "SELECT d FROM DetalleAbonos d WHERE d.detalleAbonosPK.facturaSerie = :facturaSerie"),
        @NamedQuery(name = "DetalleAbonos.findByDocumentoCodigo", query = "SELECT d FROM DetalleAbonos d WHERE d.documentoCodigo = :documentoCodigo"),
        @NamedQuery(name = "DetalleAbonos.findByProgramaCodigo", query = "SELECT d FROM DetalleAbonos d WHERE d.programaCodigo = :programaCodigo"),
        @NamedQuery(name = "DetalleAbonos.findByDetalleAbonoFecha", query = "SELECT d FROM DetalleAbonos d WHERE d.detalleAbonoFecha = :detalleAbonoFecha"),
        @NamedQuery(name = "DetalleAbonos.findByDetalleAbonoCantidad", query = "SELECT d FROM DetalleAbonos d WHERE d.detalleAbonoCantidad = :detalleAbonoCantidad")})
public class DetalleAbonos implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected DetalleAbonosPK detalleAbonosPK;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 2)
    @Column(name = "documento_codigo")
    private String documentoCodigo;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 3)
    @Column(name = "programa_codigo")
    private String programaCodigo;
    @Basic(optional = false)
    @NotNull
    @Column(name = "detalle_abono_fecha")
    @Temporal(TemporalType.DATE)
    private Date detalleAbonoFecha;
    // @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 = "detalle_abono_cantidad")
    private BigDecimal detalleAbonoCantidad;
    @JoinColumns({
            @JoinColumn(name = "abono_codigo", referencedColumnName = "abono_codigo", insertable = false, updatable = false),
            @JoinColumn(name = "abono_tipo", referencedColumnName = "abono_tipo", insertable = false, updatable = false),
            @JoinColumn(name = "abono_anulado", referencedColumnName = "abono_anulado", insertable = false, updatable = false)})
    @ManyToOne(optional = false)
    private Abonos abonos;

    public DetalleAbonos() {
    }

    public DetalleAbonos(DetalleAbonosPK detalleAbonosPK) {
        this.detalleAbonosPK = detalleAbonosPK;
    }

    public DetalleAbonos(DetalleAbonosPK detalleAbonosPK, String documentoCodigo, String programaCodigo, Date detalleAbonoFecha, BigDecimal detalleAbonoCantidad) {
        this.detalleAbonosPK = detalleAbonosPK;
        this.documentoCodigo = documentoCodigo;
        this.programaCodigo = programaCodigo;
        this.detalleAbonoFecha = detalleAbonoFecha;
        this.detalleAbonoCantidad = detalleAbonoCantidad;
    }

    public DetalleAbonos(Character abonoAnulado, String abonoCodigo, String abonoTipo, String facturaCodigo, String facturaSerie) {
        this.detalleAbonosPK = new DetalleAbonosPK(abonoAnulado, abonoCodigo, abonoTipo, facturaCodigo, facturaSerie);
    }

    public DetalleAbonosPK getDetalleAbonosPK() {
        return detalleAbonosPK;
    }

    public void setDetalleAbonosPK(DetalleAbonosPK detalleAbonosPK) {
        this.detalleAbonosPK = detalleAbonosPK;
    }

    public String getDocumentoCodigo() {
        return documentoCodigo;
    }

    public void setDocumentoCodigo(String documentoCodigo) {
        this.documentoCodigo = documentoCodigo;
    }

    public String getProgramaCodigo() {
        return programaCodigo;
    }

    public void setProgramaCodigo(String programaCodigo) {
        this.programaCodigo = programaCodigo;
    }

    public Date getDetalleAbonoFecha() {
        return detalleAbonoFecha;
    }

    public void setDetalleAbonoFecha(Date detalleAbonoFecha) {
        this.detalleAbonoFecha = detalleAbonoFecha;
    }

    public BigDecimal getDetalleAbonoCantidad() {
        return detalleAbonoCantidad;
    }

    public void setDetalleAbonoCantidad(BigDecimal detalleAbonoCantidad) {
        this.detalleAbonoCantidad = detalleAbonoCantidad;
    }

    public Abonos getAbonos() {
        return abonos;
    }

    public void setAbonos(Abonos abonos) {
        this.abonos = abonos;
    }

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

    @Override
    public String toString() {
        return "com.cosmodas.dbcon.DetalleAbonos[ detalleAbonosPK=" + detalleAbonosPK + " ]";
    }

}
