package com.fp.persistence.pgeneral.date;

import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.Column;
import javax.persistence.EntityManager;
import java.io.Serializable;
import javax.persistence.Table;
import com.fp.dto.hb.HibernateBean;
import javax.persistence.Version;
import java.lang.reflect.Field;
import javax.persistence.Transient;
import java.sql.Date;

/**Clase que implementa la entidad de Hibernate que hace referencia a la tabla TGENEACCOUNTINGDATEBRANCH*/
@Entity(name="TgeneAccountingDateBranch")
@Table(name="TGENEACCOUNTINGDATEBRANCH")
public class TgeneAccountingDateBranch extends com.fp.dto.AbstractDataTransport implements Serializable,HibernateBean,Cloneable{
/**
* 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 TgeneAccountingDateBranch
*/
@EmbeddedId
private TgeneAccountingDateBranchKey pk;
@Column(name="USERCODE", nullable=true)

/**
* Codigo de usuario
*/
private String usercode;

@Version
@Column(name="RECORDVERSION", nullable=true)

/**
* Optimistic locking del registro
*/
private Integer recordversion;

@Column(name="REALDATE", nullable=true)

/**
* Fecha real o calendario 
*/
private Date realdate;

@Column(name="ACCOUNTINGDATE", nullable=false)

/**
* Fecha contable de la sucursal
*/
private Date accountingdate;

@Column(name="WORKINGDATE", nullable=true)

/**
* Fecha de trabajo de la aplicacion
*/
private Date workingdate;

@Column(name="PREVIOUSACCOUNTINGDATE", nullable=true)

/**
* Fecha contable anterior a la fecha  contable actual
*/
private Date previousaccountingdate;

@Column(name="NEXTACCOUNTINGDATE", nullable=true)

/**
* Proxima fecha contable  a la fecha  contable actual
*/
private Date nextaccountingdate;

/**Contructor por defecto*/
public TgeneAccountingDateBranch(){
}
/**Contructor de TgeneAccountingDateBranch
@param pPk Clave Primaria del entity
@param pAccountingdate Fecha contable de la sucursal
*/
public TgeneAccountingDateBranch(TgeneAccountingDateBranchKey pPk,Date pAccountingdate){
 this();
 pk=pPk;
 accountingdate=pAccountingdate;
}
/**
* 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 TgeneAccountingDateBranch
*/
public static TgeneAccountingDateBranch find(EntityManager pEntityManager,TgeneAccountingDateBranchKey pKey) throws Exception{
    TgeneAccountingDateBranch obj = pEntityManager.find(TgeneAccountingDateBranch.class,pKey);
    return obj;
}
/**Entrega la Clave primaria de TgeneAccountingDateBranch
@return El objeto que referencia a la Clave primaria de TgeneAccountingDateBranch
*/
public TgeneAccountingDateBranchKey getPk(){
  return pk;
}
/**Fija un nuevo valor a la Clave primaria de TgeneAccountingDateBranch
@param pPk El objeto que referencia a la nueva Clave primaria de TgeneAccountingDateBranch
*/
public void setPk(TgeneAccountingDateBranchKey pPk){
  pk=pPk;
}
/**Obtiene el valor de usercode
@return valor de usercode*/
public String getUsercode(){
  return usercode;
}
/**Fija el valor de usercode
@param pUsercode nuevo Valor de usercode*/
public void setUsercode(String pUsercode){
  usercode=pUsercode;
}

/**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 realdate
@return valor de realdate*/
public Date getRealdate(){
  return realdate;
}
/**Fija el valor de realdate
@param pRealdate nuevo Valor de realdate*/
public void setRealdate(Date pRealdate){
  realdate=pRealdate;
}

/**Obtiene el valor de accountingdate
@return valor de accountingdate*/
public Date getAccountingdate(){
  return accountingdate;
}
/**Fija el valor de accountingdate
@param pAccountingdate nuevo Valor de accountingdate*/
public void setAccountingdate(Date pAccountingdate){
  accountingdate=pAccountingdate;
}

/**Obtiene el valor de workingdate
@return valor de workingdate*/
public Date getWorkingdate(){
  return workingdate;
}
/**Fija el valor de workingdate
@param pWorkingdate nuevo Valor de workingdate*/
public void setWorkingdate(Date pWorkingdate){
  workingdate=pWorkingdate;
}

/**Obtiene el valor de previousaccountingdate
@return valor de previousaccountingdate*/
public Date getPreviousaccountingdate(){
  return previousaccountingdate;
}
/**Fija el valor de previousaccountingdate
@param pPreviousaccountingdate nuevo Valor de previousaccountingdate*/
public void setPreviousaccountingdate(Date pPreviousaccountingdate){
  previousaccountingdate=pPreviousaccountingdate;
}

/**Obtiene el valor de nextaccountingdate
@return valor de nextaccountingdate*/
public Date getNextaccountingdate(){
  return nextaccountingdate;
}
/**Fija el valor de nextaccountingdate
@param pNextaccountingdate nuevo Valor de nextaccountingdate*/
public void setNextaccountingdate(Date pNextaccountingdate){
  nextaccountingdate=pNextaccountingdate;
}

public boolean equals(Object rhs){
    if (rhs == null)return false;
    if (! (rhs instanceof TgeneAccountingDateBranch))return false;
    TgeneAccountingDateBranch that = (TgeneAccountingDateBranch) 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 TgeneAccountingDateBranch
@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;
}
/**Implementación 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;
	}
/**Implementación de la creación de un bean en blanco TgeneAccountingDateBranch
*/
public Object createInstance(){
 TgeneAccountingDateBranch instance=new TgeneAccountingDateBranch();	
 instance.setPk(new TgeneAccountingDateBranchKey());
 return instance;
}
/**Clona la entidad TgeneAccountingDateBranch
@see com.fp.dto.hb.HibernateBean#cloneMe()
*/
public Object cloneMe() throws CloneNotSupportedException{
  TgeneAccountingDateBranch p=(TgeneAccountingDateBranch)this.clone();
  p.setPk((TgeneAccountingDateBranchKey)this.pk.cloneMe());
  return p;
}
}
