package com.fp.persistence.pcustomer.people;

import java.sql.Timestamp;
import com.fp.dto.hb.Log;
import java.io.Serializable;
import javax.persistence.Table;
import java.math.BigDecimal;
import com.fp.dto.hb.HibernateBean;
import javax.persistence.Version;
import javax.persistence.Entity;
import javax.persistence.EmbeddedId;
import javax.persistence.EntityManager;
import javax.persistence.Column;
import java.lang.reflect.Field;
import javax.persistence.Transient;
import java.sql.Date;
import javax.persistence.*;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;

/**
 * Clase que implementa la entidad de Hibernate que hace referencia a la tabla TCUSTPEOPLELOAN
 */
@Entity(name = "TcustPeopleLoan")
@Table(name = "TCUSTPEOPLELOAN")
public class TcustPeopleLoan extends com.fp.dto.AbstractDataTransport implements Serializable, HibernateBean, Cloneable, Log {

    /**
     * HashCode asociado con la Instancia
     */
    @Transient
    private int hashValue = 0;
    /**
     * Version de la Clase
     */
    private static final long serialVersionUID = 1L;
    /**
     * Clave primaria de la Entidad TcustPeopleLoan
     */
    @EmbeddedId
    @GenericGenerator(name = "seq_id", strategy = "com.fp.general.keygen.SubSequenceKey", parameters = {
        @Parameter(name = "sql", value = "select coalesce(max(LOANSEQUENCE),0)+1 from TCUSTPEOPLELOAN where personcode=:code"),
        @Parameter(name = "type", value = "java.lang.Integer"),
        @Parameter(name = "param", value = "code,pk.personcode"),
        @Parameter(name = "field", value = "loansequence")})
    @GeneratedValue(generator = "seq_id")
    private TcustPeopleLoanKey pk;
    @Column(name = "DATEFROM", nullable = true)
    /**
     * Fecha desde la cual esta vigente el registro
     */
    private Timestamp datefrom;
    @Version
    @Column(name = "RECORDVERSION", nullable = true)
    /**
     * Optimistic locking del registro
     */
    private Integer recordversion;
    @Column(name = "CREDITRATINGCATALOG", nullable = true)
    /**
     * Codigo de catalogo 1, normal, 2 deficiente, dudoso, 3 perdida
     */
    private String creditratingcatalog;
    @Column(name = "CREDITRATINGCATALOGCODE", nullable = true)
    /**
     * Codigo de tabla de catalogo CREDITRATING, de la calificacion de creditos
     */
    private String creditratingcatalogcode;
    @Column(name = "CREDITTYPECLIENTCATALOG", nullable = true)
    /**
     * Tipos de credito
     */
    private String credittypeclientcatalog;
    @Column(name = "CREDITTYPECLIENTCATALOGCODE", nullable = true)
    /**
     * Codigo de tabla de catalogo CREDITTYPECLIENT, para tipos de crédito
     */
    private String credittypeclientcatalogcode;
    @Column(name = "FREQUENCYCLIENTCATALOG", nullable = true)
    /**
     * Tipos de credito
     */
    private String frequencyclientcatalog;
    @Column(name = "FREQUENCYCLIENTCATALOGCODE", nullable = true)
    /**
     * Codigo de tabla de catalogo FREQUENCYCLIENT, para frecuencias en clientes
     */
    private String frequencyclientcatalogcode;
    @Column(name = "CURRENCYCODE", nullable = true)
    /**
     * Codigo de moneda
     */
    private String currencycode;
    @Column(name = "BANKPERSONCODE", nullable = true)
    /**
     * Codigo de persona asociado a la institucion fincnaiera en la cual el cliente matiene el prestamo
     */
    private Integer bankpersoncode;
    @Column(name = "BANKNAME", nullable = true)
    /**
     * Nombre de la institucion financiera en la cual el cliente mantiene la operacion
     */
    private String bankname;
    @Column(name = "ORIGINALAMONT", nullable = true)
    /**
     * Monto original del prestamo
     */
    private BigDecimal originalamont;
    @Column(name = "BALANCE", nullable = true)
    /**
     * Saldo del prestamo.
     */
    private BigDecimal balance;
    @Column(name = "BALANCEDATE", nullable = true)
    /**
     * Fecha a la cual se ingresa el saldo del prestamo
     */
    private Date balancedate;
    @Column(name = "QUOTAAMOUNT", nullable = true)
    /**
     * Valor de la cuota, de acuerdo a la frecuencia de pago
     */
    private BigDecimal quotaamount;
    @Column(name = "INGRESSUSERCODE", nullable = true)
    /**
     * Codigo de usuario
     */
    private String ingressusercode;
    @Column(name = "MODIFYUSERCODE", nullable = true)
    /**
     * Codigo de usuario
     */
    private String modifyusercode;

    /**
     * Contructor por defecto
     */
    public TcustPeopleLoan() {
    }

    /**
     * Contructor de TcustPeopleLoan
     *
     * @param pPk Clave Primaria del entity
     */
    public TcustPeopleLoan(TcustPeopleLoanKey pPk) {
        this();
        pk = pPk;
    }

    /**
     * Metodo que entrega datos de la tabla dada la clave primaria.
     *
     * @param pEntityManager referencia de la session a obtener datos del bean.
     * @param pKey Caleve primaria del bean.
     * @return TcustPeopleLoan
     */
    public static TcustPeopleLoan find(EntityManager pEntityManager, TcustPeopleLoanKey pKey) throws Exception {
        TcustPeopleLoan obj = pEntityManager.find(TcustPeopleLoan.class, pKey);
        return obj;
    }

    /**
     * Entrega la Clave primaria de TcustPeopleLoan
     *
     * @return El objeto que referencia a la Clave primaria de TcustPeopleLoan
     */
    public TcustPeopleLoanKey getPk() {
        return pk;
    }

    /**
     * Fija un nuevo valor a la Clave primaria de TcustPeopleLoan
     *
     * @param pPk El objeto que referencia a la nueva Clave primaria de TcustPeopleLoan
     */
    public void setPk(TcustPeopleLoanKey pPk) {
        pk = pPk;
    }

    /**
     * Obtiene el valor de datefrom
     *
     * @return valor de datefrom
     */
    public Timestamp getDatefrom() {
        return datefrom;
    }

    /**
     * Fija el valor de datefrom
     *
     * @param pDatefrom nuevo Valor de datefrom
     */
    public void setDatefrom(Timestamp pDatefrom) {
        datefrom = pDatefrom;
    }

    /**
     * Obtiene el valor de recordversion
     *
     * @return valor de recordversion
     */
    public Integer getRecordversion() {
        return recordversion;
    }

    /**
     * Fija el valor de recordversion
     *
     * @param pRecordversion nuevo Valor de recordversion
     */
    public void setRecordversion(Integer pRecordversion) {
        recordversion = pRecordversion;
    }

    /**
     * Obtiene el valor de creditratingcatalog
     *
     * @return valor de creditratingcatalog
     */
    public String getCreditratingcatalog() {
        return creditratingcatalog;
    }

    /**
     * Fija el valor de creditratingcatalog
     *
     * @param pCreditratingcatalog nuevo Valor de creditratingcatalog
     */
    public void setCreditratingcatalog(String pCreditratingcatalog) {
        creditratingcatalog = pCreditratingcatalog;
    }

    /**
     * Obtiene el valor de creditratingcatalogcode
     *
     * @return valor de creditratingcatalogcode
     */
    public String getCreditratingcatalogcode() {
        return creditratingcatalogcode;
    }

    /**
     * Fija el valor de creditratingcatalogcode
     *
     * @param pCreditratingcatalogcode nuevo Valor de creditratingcatalogcode
     */
    public void setCreditratingcatalogcode(String pCreditratingcatalogcode) {
        creditratingcatalogcode = pCreditratingcatalogcode;
    }

    /**
     * Obtiene el valor de credittypeclientcatalog
     *
     * @return valor de credittypeclientcatalog
     */
    public String getCredittypeclientcatalog() {
        return credittypeclientcatalog;
    }

    /**
     * Fija el valor de credittypeclientcatalog
     *
     * @param pCredittypeclientcatalog nuevo Valor de credittypeclientcatalog
     */
    public void setCredittypeclientcatalog(String pCredittypeclientcatalog) {
        credittypeclientcatalog = pCredittypeclientcatalog;
    }

    /**
     * Obtiene el valor de credittypeclientcatalogcode
     *
     * @return valor de credittypeclientcatalogcode
     */
    public String getCredittypeclientcatalogcode() {
        return credittypeclientcatalogcode;
    }

    /**
     * Fija el valor de credittypeclientcatalogcode
     *
     * @param pCredittypeclientcatalogcode nuevo Valor de credittypeclientcatalogcode
     */
    public void setCredittypeclientcatalogcode(String pCredittypeclientcatalogcode) {
        credittypeclientcatalogcode = pCredittypeclientcatalogcode;
    }

    /**
     * Obtiene el valor de frequencyclientcatalog
     *
     * @return valor de frequencyclientcatalog
     */
    public String getFrequencyclientcatalog() {
        return frequencyclientcatalog;
    }

    /**
     * Fija el valor de frequencyclientcatalog
     *
     * @param pFrequencyclientcatalog nuevo Valor de frequencyclientcatalog
     */
    public void setFrequencyclientcatalog(String pFrequencyclientcatalog) {
        frequencyclientcatalog = pFrequencyclientcatalog;
    }

    /**
     * Obtiene el valor de frequencyclientcatalogcode
     *
     * @return valor de frequencyclientcatalogcode
     */
    public String getFrequencyclientcatalogcode() {
        return frequencyclientcatalogcode;
    }

    /**
     * Fija el valor de frequencyclientcatalogcode
     *
     * @param pFrequencyclientcatalogcode nuevo Valor de frequencyclientcatalogcode
     */
    public void setFrequencyclientcatalogcode(String pFrequencyclientcatalogcode) {
        frequencyclientcatalogcode = pFrequencyclientcatalogcode;
    }

    /**
     * Obtiene el valor de currencycode
     *
     * @return valor de currencycode
     */
    public String getCurrencycode() {
        return currencycode;
    }

    /**
     * Fija el valor de currencycode
     *
     * @param pCurrencycode nuevo Valor de currencycode
     */
    public void setCurrencycode(String pCurrencycode) {
        currencycode = pCurrencycode;
    }

    /**
     * Obtiene el valor de bankpersoncode
     *
     * @return valor de bankpersoncode
     */
    public Integer getBankpersoncode() {
        return bankpersoncode;
    }

    /**
     * Fija el valor de bankpersoncode
     *
     * @param pBankpersoncode nuevo Valor de bankpersoncode
     */
    public void setBankpersoncode(Integer pBankpersoncode) {
        bankpersoncode = pBankpersoncode;
    }

    /**
     * Obtiene el valor de bankname
     *
     * @return valor de bankname
     */
    public String getBankname() {
        return bankname;
    }

    /**
     * Fija el valor de bankname
     *
     * @param pBankname nuevo Valor de bankname
     */
    public void setBankname(String pBankname) {
        bankname = pBankname;
    }

    /**
     * Obtiene el valor de originalamont
     *
     * @return valor de originalamont
     */
    public BigDecimal getOriginalamont() {
        return originalamont;
    }

    /**
     * Fija el valor de originalamont
     *
     * @param pOriginalamont nuevo Valor de originalamont
     */
    public void setOriginalamont(BigDecimal pOriginalamont) {
        originalamont = pOriginalamont;
    }

    /**
     * Obtiene el valor de balance
     *
     * @return valor de balance
     */
    public BigDecimal getBalance() {
        return balance;
    }

    /**
     * Fija el valor de balance
     *
     * @param pBalance nuevo Valor de balance
     */
    public void setBalance(BigDecimal pBalance) {
        balance = pBalance;
    }

    /**
     * Obtiene el valor de balancedate
     *
     * @return valor de balancedate
     */
    public Date getBalancedate() {
        return balancedate;
    }

    /**
     * Fija el valor de balancedate
     *
     * @param pBalancedate nuevo Valor de balancedate
     */
    public void setBalancedate(Date pBalancedate) {
        balancedate = pBalancedate;
    }

    /**
     * Obtiene el valor de quotaamount
     *
     * @return valor de quotaamount
     */
    public BigDecimal getQuotaamount() {
        return quotaamount;
    }

    /**
     * Fija el valor de quotaamount
     *
     * @param pQuotaamount nuevo Valor de quotaamount
     */
    public void setQuotaamount(BigDecimal pQuotaamount) {
        quotaamount = pQuotaamount;
    }

    /**
     * Obtiene el valor de ingressusercode
     *
     * @return valor de ingressusercode
     */
    public String getIngressusercode() {
        return ingressusercode;
    }

    /**
     * Fija el valor de ingressusercode
     *
     * @param pIngressusercode nuevo Valor de ingressusercode
     */
    public void setIngressusercode(String pIngressusercode) {
        ingressusercode = pIngressusercode;
    }

    /**
     * Obtiene el valor de modifyusercode
     *
     * @return valor de modifyusercode
     */
    public String getModifyusercode() {
        return modifyusercode;
    }

    /**
     * Fija el valor de modifyusercode
     *
     * @param pModifyusercode nuevo Valor de modifyusercode
     */
    public void setModifyusercode(String pModifyusercode) {
        modifyusercode = pModifyusercode;
    }

    public boolean equals(Object rhs) {
        if (rhs == null) {
            return false;
        }
        if (!(rhs instanceof TcustPeopleLoan)) {
            return false;
        }
        TcustPeopleLoan that = (TcustPeopleLoan) rhs;
        if (this.getPk() == null || that.getPk() == null) {
            return false;
        }
        return (this.getPk().equals(that.getPk()));
    }

    /**
     * Implementacion del metodo hashCode de la la entidad TcustPeopleLoan
     *
     * @return el hashCode la instancia
     */
    public int hashCode() {
        if (this.hashValue == 0) {
            int result = 17;
            if (this.getPk() == null) {
                result = super.hashCode();
            } else {
                result = this.getPk().hashCode();
            }
            this.hashValue = result;
        }
        return this.hashValue;
    }

    /**
     * Implementacion toString
     */
    public String toString() {
        Field[] fs = this.getClass().getDeclaredFields();
        String data = "";
        for (Field f : fs) {
            try {
                String name = f.getName();
                if (f.getType().getName().compareTo("java.util.Set") == 0) {
                    continue;
                }
                if (name.compareTo("hashValue") == 0 || name.compareTo("serialVersionUID") == 0) {
                    continue;
                }
                data += name + "=" + f.get(this) + ";";
            } catch (Exception e) {
                continue;
            }
        }
        if (data.compareTo("") == 0) {
            data = super.toString();
        }
        return data;
    }

    /**
     * Implementacion de la creacion de un bean en blanco TcustPeopleLoan
     */
    public Object createInstance() {
        TcustPeopleLoan instance = new TcustPeopleLoan();
        instance.setPk(new TcustPeopleLoanKey());
        return instance;
    }

    /**
     * Clona la entidad TcustPeopleLoan
     *
     * @see com.fp.dto.hb.HibernateBean#cloneMe()
     */
    public Object cloneMe() throws CloneNotSupportedException {
        TcustPeopleLoan p = (TcustPeopleLoan) this.clone();
        p.setPk((TcustPeopleLoanKey) this.pk.cloneMe());
        return p;
    }

    public Object getId() {
        return this.pk;
    }
}
