/*
 * 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.FetchType;
import javax.persistence.JoinColumn;
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 = "cargos")
@XmlRootElement
@NamedQueries({
        @NamedQuery(name = "Cargos.findAll", query = "SELECT c FROM Cargos c")
        ,
        @NamedQuery(name = "Cargos.findByFacturaCodigo", query = "SELECT c FROM Cargos c WHERE c.cargosPK.facturaCodigo = :facturaCodigo")
        ,
        @NamedQuery(name = "Cargos.findByProgramaCodigo", query = "SELECT c FROM Cargos c WHERE c.programaCodigo = :programaCodigo")
        ,
        @NamedQuery(name = "Cargos.findByDocumentoCodigo", query = "SELECT c FROM Cargos c WHERE c.cargosPK.documentoCodigo = :documentoCodigo")
        ,
        @NamedQuery(name = "Cargos.findByFacturaSerie", query = "SELECT c FROM Cargos c WHERE c.cargosPK.facturaSerie = :facturaSerie")
        ,
        @NamedQuery(name = "Cargos.findByCargoFechaFactura", query = "SELECT c FROM Cargos c WHERE c.cargoFechaFactura = :cargoFechaFactura")
        ,
        @NamedQuery(name = "Cargos.findByCargoValor", query = "SELECT c FROM Cargos c WHERE c.cargoValor = :cargoValor")
        ,
        @NamedQuery(name = "Cargos.findByCargoPendiente", query = "SELECT c FROM Cargos c WHERE c.cargoPendiente = :cargoPendiente")
        ,
        @NamedQuery(name = "Cargos.findByCargoPublico", query = "SELECT c FROM Cargos c WHERE c.cargoPublico = :cargoPublico")
        ,
        @NamedQuery(name = "Cargos.findByCargoEnvioTarjeta", query = "SELECT c FROM Cargos c WHERE c.cargoEnvioTarjeta = :cargoEnvioTarjeta")
        ,
        @NamedQuery(name = "Cargos.findByCredito", query = "SELECT c FROM Cargos c WHERE c.credito = :credito")
        ,
        @NamedQuery(name = "Cargos.findByBazar", query = "SELECT c FROM Cargos c WHERE c.bazar = :bazar")
        ,
        @NamedQuery(name = "Cargos.findByOtrodesc", query = "SELECT c FROM Cargos c WHERE c.otrodesc = :otrodesc")
        ,
//personalizados----------------------------------------
        @NamedQuery(name = "Cargos.UltimaFactura", query = "SELECT MAX(c.cargosPK.facturaCodigo) FROM Cargos c WHERE c.cargosPK.documentoCodigo = :documentoCodigo AND c.cargosPK.facturaSerie = :facturaSerie")

})
public class Cargos implements Serializable {

    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected CargosPK cargosPK;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 3)
    @Column(name = "programa_codigo")
    private String programaCodigo;
    @Basic(optional = false)
    @NotNull
    @Column(name = "cargo_fecha_factura")
    @Temporal(TemporalType.DATE)
    private Date cargoFechaFactura;
    // @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 = "cargo_valor")
    private BigDecimal cargoValor;
    @Basic(optional = false)
    @NotNull
    @Column(name = "cargo_pendiente")
    private BigDecimal cargoPendiente;
    @Basic(optional = false)
    @NotNull
    @Column(name = "cargo_publico")
    private BigDecimal cargoPublico;
    @Column(name = "cargo_envio_tarjeta")
    private Boolean cargoEnvioTarjeta;
    @Basic(optional = false)
    @NotNull
    @Column(name = "credito")
    private boolean credito;
    @Basic(optional = false)
    @NotNull
    @Column(name = "bazar")
    private boolean bazar;
    @Basic(optional = false)
    @NotNull
    @Column(name = "otrodesc")
    private BigDecimal otrodesc;
    @JoinColumn(name = "consultor_codigo", referencedColumnName = "consultor_codigo")
    @ManyToOne(optional = true, fetch = FetchType.LAZY)
    private Consultores consultorCodigo;
    @JoinColumn(name = "sucursal_codigo", referencedColumnName = "sucursal_codigo")
    @ManyToOne(optional = true, fetch = FetchType.LAZY)
    private Sucursales sucursalCodigo;

    public Cargos() {
    }

    public Cargos(CargosPK cargosPK) {
        this.cargosPK = cargosPK;
    }

    public Cargos(CargosPK cargosPK, String programaCodigo, Date cargoFechaFactura, BigDecimal cargoValor, BigDecimal cargoPendiente, BigDecimal cargoPublico, boolean credito, boolean bazar, BigDecimal otrodesc) {
        this.cargosPK = cargosPK;
        this.programaCodigo = programaCodigo;
        this.cargoFechaFactura = cargoFechaFactura;
        this.cargoValor = cargoValor;
        this.cargoPendiente = cargoPendiente;
        this.cargoPublico = cargoPublico;
        this.credito = credito;
        this.bazar = bazar;
        this.otrodesc = otrodesc;
    }

    public Cargos(String facturaCodigo, String documentoCodigo, String facturaSerie) {
        this.cargosPK = new CargosPK(facturaCodigo, documentoCodigo, facturaSerie);
    }

    public CargosPK getCargosPK() {
        return cargosPK;
    }

    public void setCargosPK(CargosPK cargosPK) {
        this.cargosPK = cargosPK;
    }

    public String getProgramaCodigo() {
        return programaCodigo;
    }

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

    public Date getCargoFechaFactura() {
        return cargoFechaFactura;
    }

    public void setCargoFechaFactura(Date cargoFechaFactura) {
        this.cargoFechaFactura = cargoFechaFactura;
    }

    public BigDecimal getCargoValor() {
        return cargoValor;
    }

    public void setCargoValor(BigDecimal cargoValor) {
        this.cargoValor = cargoValor;
    }

    public BigDecimal getCargoPendiente() {
        return cargoPendiente;
    }

    public void setCargoPendiente(BigDecimal cargoPendiente) {
        this.cargoPendiente = cargoPendiente;
    }

    public BigDecimal getCargoPublico() {
        return cargoPublico;
    }

    public void setCargoPublico(BigDecimal cargoPublico) {
        this.cargoPublico = cargoPublico;
    }

    public Boolean getCargoEnvioTarjeta() {
        return cargoEnvioTarjeta;
    }

    public void setCargoEnvioTarjeta(Boolean cargoEnvioTarjeta) {
        this.cargoEnvioTarjeta = cargoEnvioTarjeta;
    }

    public boolean getCredito() {
        return credito;
    }

    public void setCredito(boolean credito) {
        this.credito = credito;
    }

    public boolean getBazar() {
        return bazar;
    }

    public void setBazar(boolean bazar) {
        this.bazar = bazar;
    }

    public BigDecimal getOtrodesc() {
        return otrodesc;
    }

    public void setOtrodesc(BigDecimal otrodesc) {
        this.otrodesc = otrodesc;
    }

    public Consultores getConsultorCodigo() {
        return consultorCodigo;
    }

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

    public Sucursales getSucursalCodigo() {
        return sucursalCodigo;
    }

    public void setSucursalCodigo(Sucursales sucursalCodigo) {
        this.sucursalCodigo = sucursalCodigo;
    }

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

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

}
