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
 * TCUSTPEOPLEREALASSETS
 */
@Entity(name = "TcustPeopleRealAssets")
@Table(name = "TCUSTPEOPLEREALASSETS")
public class TcustPeopleRealAssets 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 TcustPeopleRealAssets
     */
    @EmbeddedId
    @GenericGenerator(name = "seq_id", strategy = "com.fp.general.keygen.SubSequenceKey", parameters = {
        @Parameter(name = "sql", value = "select coalesce(max(ASSETSSEQUENCE),0)+1 from TCUSTPEOPLEREALASSETS where personcode=:code"),
        @Parameter(name = "type", value = "java.lang.Integer"),
        @Parameter(name = "param", value = "code,pk.personcode"),
        @Parameter(name = "field", value = "assetssequence")})
    @GeneratedValue(generator = "seq_id")
    private TcustPeopleRealAssetsKey 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 = "REALASSETSTYPECATALOG", nullable = true)
    /**
     * Codigo de catalogo de tipos de bien 1, casa, 2 oficina, 3 terreno
     */
    private String realassetstypecatalog;
    @Column(name = "REALASSETSTYPECATALOGCODE", nullable = true)
    /**
     * Codigo de tabla de catalogo REALASSETSTYPE, del tipo de bien
     */
    private String realassetstypecatalogcode;
    @Column(name = "COUNTRYCODE", nullable = true)
    /**
     * Codigo de pais
     */
    private String countrycode;
    @Column(name = "PROVINCECODE", nullable = true)
    /**
     * Codigo de provincia
     */
    private String provincecode;
    @Column(name = "CANTONCODE", nullable = true)
    /**
     * Codigo de canton
     */
    private String cantoncode;
    @Column(name = "CITYCODE", nullable = true)
    /**
     * Codigo de cuidad
     */
    private String citycode;
    @Column(name = "LOCATION", nullable = true)
    /**
     * Ubicacion de la propiedad
     */
    private String location;
    @Column(name = "CURRENCYCODE", nullable = true)
    /**
     * Codigo de moneda
     */
    private String currencycode;
    @Column(name = "ASSESSMENT", nullable = true)
    /**
     * Valor del avaluo del bien
     */
    private BigDecimal assessment;
    @Column(name = "ASSESSMENTDATE", nullable = true)
    /**
     * Fecha de avaluo.
     */
    private Date assessmentdate;
    @Column(name = "MORTGAGEAMOUNT", nullable = true)
    /**
     * Monto original de la hipoteca
     */
    private BigDecimal mortgageamount;
    @Column(name = "MORTGAGEDATE", nullable = true)
    /**
     * Fecha de la hipoteca
     */
    private Date mortgagedate;
    @Column(name = "MORTGAGEBALANCE", nullable = true)
    /**
     * Saldo de la hipoteca
     */
    private BigDecimal mortgagebalance;
    @Column(name = "MORTGAGEPERSONCODE", nullable = true)
    /**
     * Codigo de persona a la que esta hipotecado el bien
     */
    private Integer mortgagepersoncode;
    @Column(name = "PARROQUIACODE", nullable = true)
    /**
     * Codigo de parroquia
     */
    private String parroquiacode;
    @Column(name = "MORTGAGENAME", nullable = true)
    /**
     * Nombre de la entidad poseedora de la hipoteca
     */
    private String mortgagename;
    @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 TcustPeopleRealAssets() {
    }

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

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

    /**
     * Fija un nuevo valor a la Clave primaria de TcustPeopleRealAssets
     *
     * @param pPk El objeto que referencia a la nueva Clave primaria de
     * TcustPeopleRealAssets
     */
    public void setPk(TcustPeopleRealAssetsKey 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 realassetstypecatalog
     *
     * @return valor de realassetstypecatalog
     */
    public String getRealassetstypecatalog() {
        return this.realassetstypecatalog;
    }

    /**
     * Fija el valor de realassetstypecatalog
     *
     * @param pRealassetstypecatalog nuevo Valor de realassetstypecatalog
     */
    public void setRealassetstypecatalog(String pRealassetstypecatalog) {
        this.realassetstypecatalog = pRealassetstypecatalog;
    }

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

    /**
     * Fija el valor de realassetstypecatalogcode
     *
     * @param pRealassetstypecatalogcode nuevo Valor de
     * realassetstypecatalogcode
     */
    public void setRealassetstypecatalogcode(String pRealassetstypecatalogcode) {
        this.realassetstypecatalogcode = pRealassetstypecatalogcode;
    }

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

    /**
     * Fija el valor de countrycode
     *
     * @param pCountrycode nuevo Valor de countrycode
     */
    public void setCountrycode(String pCountrycode) {
        this.countrycode = pCountrycode;
    }

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

    /**
     * Fija el valor de provincecode
     *
     * @param pProvincecode nuevo Valor de provincecode
     */
    public void setProvincecode(String pProvincecode) {
        this.provincecode = pProvincecode;
    }

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

    /**
     * Fija el valor de cantoncode
     *
     * @param pCantoncode nuevo Valor de cantoncode
     */
    public void setCantoncode(String pCantoncode) {
        this.cantoncode = pCantoncode;
    }

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

    /**
     * Fija el valor de citycode
     *
     * @param pCitycode nuevo Valor de citycode
     */
    public void setCitycode(String pCitycode) {
        this.citycode = pCitycode;
    }

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

    /**
     * Fija el valor de location
     *
     * @param pLocation nuevo Valor de location
     */
    public void setLocation(String pLocation) {
        this.location = pLocation;
    }

    /**
     * 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 assessment
     *
     * @return valor de assessment
     */
    public BigDecimal getAssessment() {
        return this.assessment;
    }

    /**
     * Fija el valor de assessment
     *
     * @param pAssessment nuevo Valor de assessment
     */
    public void setAssessment(BigDecimal pAssessment) {
        this.assessment = pAssessment;
    }

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

    /**
     * Fija el valor de assessmentdate
     *
     * @param pAssessmentdate nuevo Valor de assessmentdate
     */
    public void setAssessmentdate(Date pAssessmentdate) {
        this.assessmentdate = pAssessmentdate;
    }

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

    /**
     * Fija el valor de mortgageamount
     *
     * @param pMortgageamount nuevo Valor de mortgageamount
     */
    public void setMortgageamount(BigDecimal pMortgageamount) {
        this.mortgageamount = pMortgageamount;
    }

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

    /**
     * Fija el valor de mortgagedate
     *
     * @param pMortgagedate nuevo Valor de mortgagedate
     */
    public void setMortgagedate(Date pMortgagedate) {
        this.mortgagedate = pMortgagedate;
    }

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

    /**
     * Fija el valor de mortgagebalance
     *
     * @param pMortgagebalance nuevo Valor de mortgagebalance
     */
    public void setMortgagebalance(BigDecimal pMortgagebalance) {
        this.mortgagebalance = pMortgagebalance;
    }

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

    /**
     * Fija el valor de mortgagepersoncode
     *
     * @param pMortgagepersoncode nuevo Valor de mortgagepersoncode
     */
    public void setMortgagepersoncode(Integer pMortgagepersoncode) {
        this.mortgagepersoncode = pMortgagepersoncode;
    }

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

    /**
     * Fija el valor de parroquiacode
     *
     * @param pParroquiacode nuevo Valor de parroquiacode
     */
    public void setParroquiacode(String pParroquiacode) {
        this.parroquiacode = pParroquiacode;
    }

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

    /**
     * Fija el valor de mortgagename
     *
     * @param pMortgagename nuevo Valor de mortgagename
     */
    public void setMortgagename(String pMortgagename) {
        this.mortgagename = pMortgagename;
    }

    /**
     * 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 TcustPeopleRealAssets)) {
            return false;
        }
        TcustPeopleRealAssets that = (TcustPeopleRealAssets) 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
     * TcustPeopleRealAssets
     *
     * @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
     * TcustPeopleRealAssets
     */
    @Override
    public Object createInstance() {
        TcustPeopleRealAssets instance = new TcustPeopleRealAssets();
        instance.setPk(new TcustPeopleRealAssetsKey());
        return instance;
    }

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

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