package com.fp.persistence.pcustomer.people;

import java.io.Serializable;
import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.sql.Date;
import java.sql.Timestamp;

import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.EntityManager;
import javax.persistence.GeneratedValue;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.persistence.Version;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;

import com.fp.dto.hb.HibernateBean;
import com.fp.dto.hb.Log;

/**
 * Clase que implementa la entidad de Hibernate que hace referencia a la tabla TCUSTPEOPLEFIXEDINCOME
 */
@Entity(name = "TcustPeopleFixedIncome")
@Table(name = "TCUSTPEOPLEFIXEDINCOME")
public class TcustPeopleFixedIncome 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 TcustPeopleFixedIncome
     */
    @EmbeddedId
    @GenericGenerator(name = "seq_id", strategy = "com.fp.general.keygen.SubSequenceKey", parameters = {
            @Parameter(name = "sql", value = "select coalesce(max(FIXEDINCOMESEQUENCE),0)+1 from TCUSTPEOPLEFIXEDINCOME where personcode=:code"),
            @Parameter(name = "type", value = "java.lang.Integer"), @Parameter(name = "param", value = "code,pk.personcode"),
            @Parameter(name = "field", value = "fixedincomesequence") })
    @GeneratedValue(generator = "seq_id")
    private TcustPeopleFixedIncomeKey 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 = "FIXEDINCOMECATALOG", nullable = true)
    /**
     * Codigo de catalogo 1 Bonos del banco central, 2 Poliza, 3 Certificado de
     * inversion
     */
    private String fixedincomecatalog;

    @Column(name = "FIXEDINCOMECATALOGCODE", nullable = true)
    /**
     * Codigo de tabla de catalogo FIXEDINCOME tipo de inversion
     */
    private String fixedincomecatalogcode;

    @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 la inversion
     */
    private Integer bankpersoncode;

    @Column(name = "BANKNAME", nullable = true)
    /**
     * Nombre de la institucion financiera en la cual el cliente mantiene la
     * operacion de renta
     */
    private String bankname;

    @Column(name = "ORIGINALAMONT", nullable = true)
    /**
     * Monto original de la inversion
     */
    private BigDecimal originalamont;

    @Column(name = "RATE", nullable = true)
    /**
     * Tada de la inversion.
     */
    private BigDecimal rate;

    @Column(name = "BALANCE", nullable = true)
    /**
     * Saldo de la inversion.
     */
    private BigDecimal balance;

    @Column(name = "BALANCEDATE", nullable = true)
    /**
     * Fecha a la cual se ingresa el saldo de la inversion.
     */
    private Date balancedate;

    @Column(name = "EXPIRATIONDATE", nullable = true)
    /**
     * Fecha de vencimiento de la inversion.
     */
    private Date expirationdate;

    @Column(name = "REMARK", nullable = true)
    /**
     * Comentario.
     */
    private String remark;

    @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 TcustPeopleFixedIncome() {
    }

    /**
     * Contructor de TcustPeopleFixedIncome
     * 
     * @param pPk Clave Primaria del entity
     */
    public TcustPeopleFixedIncome(TcustPeopleFixedIncomeKey pPk) {
        this();
        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 TcustPeopleFixedIncome
     */
    public static TcustPeopleFixedIncome find(EntityManager pEntityManager, TcustPeopleFixedIncomeKey pKey) throws Exception {
        TcustPeopleFixedIncome obj = pEntityManager.find(TcustPeopleFixedIncome.class, pKey);
        return obj;
    }

    /**
     * Entrega la Clave primaria de TcustPeopleFixedIncome
     * 
     * @return El objeto que referencia a la Clave primaria de TcustPeopleFixedIncome
     */
    public TcustPeopleFixedIncomeKey getPk() {
        return this.pk;
    }

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

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

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

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

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

    /**
     * Obtiene el valor de fixedincomecatalog
     * 
     * @return valor de fixedincomecatalog
     */
    public String getFixedincomecatalog() {
        return this.fixedincomecatalog;
    }

    /**
     * Fija el valor de fixedincomecatalog
     * 
     * @param pFixedincomecatalog nuevo Valor de fixedincomecatalog
     */
    public void setFixedincomecatalog(String pFixedincomecatalog) {
        this.fixedincomecatalog = pFixedincomecatalog;
    }

    /**
     * Obtiene el valor de fixedincomecatalogcode
     * 
     * @return valor de fixedincomecatalogcode
     */
    public String getFixedincomecatalogcode() {
        return this.fixedincomecatalogcode;
    }

    /**
     * Fija el valor de fixedincomecatalogcode
     * 
     * @param pFixedincomecatalogcode nuevo Valor de fixedincomecatalogcode
     */
    public void setFixedincomecatalogcode(String pFixedincomecatalogcode) {
        this.fixedincomecatalogcode = pFixedincomecatalogcode;
    }

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

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

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

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

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

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

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

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

    /**
     * Obtiene el valor de rate
     * 
     * @return valor de rate
     */
    public BigDecimal getRate() {
        return this.rate;
    }

    /**
     * Fija el valor de rate
     * 
     * @param pRate nuevo Valor de rate
     */
    public void setRate(BigDecimal pRate) {
        this.rate = pRate;
    }

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

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

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

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

    /**
     * Obtiene el valor de expirationdate
     * 
     * @return valor de expirationdate
     */
    public Date getExpirationdate() {
        return this.expirationdate;
    }

    /**
     * Fija el valor de expirationdate
     * 
     * @param pExpirationdate nuevo Valor de expirationdate
     */
    public void setExpirationdate(Date pExpirationdate) {
        this.expirationdate = pExpirationdate;
    }

    /**
     * Obtiene el valor de remark
     * 
     * @return valor de remark
     */
    public String getRemark() {
        return this.remark;
    }

    /**
     * Fija el valor de remark
     * 
     * @param pRemark nuevo Valor de remark
     */
    public void setRemark(String pRemark) {
        this.remark = pRemark;
    }

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

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

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

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

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

    /**
     * Implementaci�n del metodo hashCode de la la entidad TcustPeopleFixedIncome
     * 
     * @return el hashCode la instancia
     */
    @Override
    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;
    }

    /**
     * Implementaci�n toString
     */
    @Override
    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;
    }

    /**
     * Implementaci�n de la creaci�n de un bean en blanco TcustPeopleFixedIncome
     */
    @Override
    public Object createInstance() {
        TcustPeopleFixedIncome instance = new TcustPeopleFixedIncome();
        instance.setPk(new TcustPeopleFixedIncomeKey());
        return instance;
    }

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

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