/*
 * 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 javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 * @author obper
 */
@Entity
@Table(name = "credito_fiscal")
@XmlRootElement
@NamedQueries({
        @NamedQuery(name = "CreditoFiscal.findAll", query = "SELECT c FROM CreditoFiscal c")
        , @NamedQuery(name = "CreditoFiscal.findByFacturaCodigo", query = "SELECT c FROM CreditoFiscal c WHERE c.creditoFiscalPK.facturaCodigo = :facturaCodigo")
        , @NamedQuery(name = "CreditoFiscal.findByConsultorCodigo", query = "SELECT c FROM CreditoFiscal c WHERE c.consultorCodigo = :consultorCodigo")
        , @NamedQuery(name = "CreditoFiscal.findByPercepcion", query = "SELECT c FROM CreditoFiscal c WHERE c.percepcion = :percepcion")
        , @NamedQuery(name = "CreditoFiscal.findBySerie", query = "SELECT c FROM CreditoFiscal c WHERE c.creditoFiscalPK.serie = :serie")})
public class CreditoFiscal implements Serializable {

    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected CreditoFiscalPK creditoFiscalPK;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 6)
    @Column(name = "consultor_codigo")
    private String consultorCodigo;
    // @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 = "percepcion")
    private BigDecimal percepcion;
    @Column(name = "Iva")
    private BigDecimal iva;
    @Column(name = "monto_SIva")
    private BigDecimal montoSIva;

    public CreditoFiscal() {
    }

    public CreditoFiscal(CreditoFiscalPK creditoFiscalPK) {
        this.creditoFiscalPK = creditoFiscalPK;
    }

    public CreditoFiscal(CreditoFiscalPK creditoFiscalPK, String consultorCodigo, BigDecimal percepcion) {
        this.creditoFiscalPK = creditoFiscalPK;
        this.consultorCodigo = consultorCodigo;
        this.percepcion = percepcion;
    }

    public CreditoFiscal(String facturaCodigo, String serie) {
        this.creditoFiscalPK = new CreditoFiscalPK(facturaCodigo, serie);
    }

    public CreditoFiscalPK getCreditoFiscalPK() {
        return creditoFiscalPK;
    }

    public void setCreditoFiscalPK(CreditoFiscalPK creditoFiscalPK) {
        this.creditoFiscalPK = creditoFiscalPK;
    }

    public String getConsultorCodigo() {
        return consultorCodigo;
    }

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

    public BigDecimal getPercepcion() {
        return percepcion;
    }

    public void setPercepcion(BigDecimal percepcion) {
        this.percepcion = percepcion;
    }

    public BigDecimal getIva() {
        return iva;
    }

    public void setIva(BigDecimal iva) {
        this.iva = iva;
    }

    public BigDecimal getMontoSIva() {
        return montoSIva;
    }

    public void setMontoSIva(BigDecimal montoSIva) {
        this.montoSIva = montoSIva;
    }

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

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

}
