maia/.svn/pristine/ac/ac6c5698bd9ff69795c49a61a83...

433 lines
11 KiB
Plaintext
Executable File
Raw Permalink Blame History

package com.fp.persistence.pgeneral.gene;
import java.io.Serializable;
import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.sql.Date;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
import javax.persistence.Query;
import javax.persistence.Table;
import javax.persistence.Transient;
import com.fp.common.helper.Constant;
import com.fp.dto.hb.HibernateBean;
/** Clase que implementa la entidad de Hibernate que hace referencia a la tabla TGENETRANSACTIONMIX */
@Entity(name = "TgeneTransactionMix")
@Table(name = "TGENETRANSACTIONMIX")
public class TgeneTransactionMix 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 TgeneTransactionMix
*/
@EmbeddedId
private TgeneTransactionMixKey pk;
@Column(name = "PERSONCODE", nullable = true)
/**
* Codigo de persona
*/
private Integer personcode;
@Column(name = "CURRENCYCODE", nullable = true)
/**
* Codigo de moneda
*/
private String currencycode;
@Column(name = "OFFICECODE", nullable = true)
/**
* Codigo de oficina
*/
private Integer officecode;
@Column(name = "BRANCHCODE", nullable = true)
/**
* Codigo de sucursal
*/
private Integer branchcode;
@Column(name = "COMPANYCODE", nullable = true)
/**
* Codigo de compania al que pertenece la oficina
*/
private Integer companycode;
@Column(name = "ACCOUNTINGDATE", nullable = true)
/**
* null
*/
private Date accountingdate;
@Column(name = "CASH", nullable = true)
/**
* null
*/
private BigDecimal cash;
@Column(name = "CHECKS", nullable = true)
/**
* null
*/
private BigDecimal checks;
@Column(name = "CASHBALANCE", nullable = true)
/**
* null
*/
private BigDecimal cashbalance;
@Column(name = "CHECKBALANCE", nullable = true)
/**
* null
*/
private BigDecimal checkbalance;
/** Contructor por defecto */
public TgeneTransactionMix() {
}
/**
* Contructor de TgeneTransactionMix
*
* @param pPk Clave Primaria del entity
*/
public TgeneTransactionMix(TgeneTransactionMixKey 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 TgeneTransactionMix
*/
public static TgeneTransactionMix find(EntityManager pEntityManager, TgeneTransactionMixKey pKey) throws Exception {
TgeneTransactionMix obj = pEntityManager.find(TgeneTransactionMix.class, pKey);
return obj;
}
/**
* Entrega la Clave primaria de TgeneTransactionMix
*
* @return El objeto que referencia a la Clave primaria de TgeneTransactionMix
*/
public TgeneTransactionMixKey getPk() {
return this.pk;
}
/**
* Fija un nuevo valor a la Clave primaria de TgeneTransactionMix
*
* @param pPk El objeto que referencia a la nueva Clave primaria de TgeneTransactionMix
*/
public void setPk(TgeneTransactionMixKey pPk) {
this.pk = pPk;
}
/**
* Obtiene el valor de personcode
*
* @return valor de personcode
*/
public Integer getPersoncode() {
return this.personcode;
}
/**
* Fija el valor de personcode
*
* @param pPersoncode nuevo Valor de personcode
*/
public void setPersoncode(Integer pPersoncode) {
this.personcode = pPersoncode;
}
/**
* 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 officecode
*
* @return valor de officecode
*/
public Integer getOfficecode() {
return this.officecode;
}
/**
* Fija el valor de officecode
*
* @param pOfficecode nuevo Valor de officecode
*/
public void setOfficecode(Integer pOfficecode) {
this.officecode = pOfficecode;
}
/**
* Obtiene el valor de branchcode
*
* @return valor de branchcode
*/
public Integer getBranchcode() {
return this.branchcode;
}
/**
* Fija el valor de branchcode
*
* @param pBranchcode nuevo Valor de branchcode
*/
public void setBranchcode(Integer pBranchcode) {
this.branchcode = pBranchcode;
}
/**
* Obtiene el valor de companycode
*
* @return valor de companycode
*/
public Integer getCompanycode() {
return this.companycode;
}
/**
* Fija el valor de companycode
*
* @param pCompanycode nuevo Valor de companycode
*/
public void setCompanycode(Integer pCompanycode) {
this.companycode = pCompanycode;
}
/**
* Obtiene el valor de accountingdate
*
* @return valor de accountingdate
*/
public Date getAccountingdate() {
return this.accountingdate;
}
/**
* Fija el valor de accountingdate
*
* @param pAccountingdate nuevo Valor de accountingdate
*/
public void setAccountingdate(Date pAccountingdate) {
this.accountingdate = pAccountingdate;
}
/**
* Obtiene el valor de cash
*
* @return valor de cash
*/
public BigDecimal getCash() {
return this.cash;
}
/**
* Fija el valor de cash
*
* @param pCash nuevo Valor de cash
*/
public void setCash(BigDecimal pCash) {
this.cash = pCash;
}
/**
* Obtiene el valor de checks
*
* @return valor de checks
*/
public BigDecimal getChecks() {
return this.checks;
}
/**
* Fija el valor de checks
*
* @param pChecks nuevo Valor de checks
*/
public void setChecks(BigDecimal pChecks) {
this.checks = pChecks;
}
/**
* Obtiene el valor de cashbalance
*
* @return valor de cashbalance
*/
public BigDecimal getCashbalance() {
return this.cashbalance;
}
/**
* Fija el valor de cashbalance
*
* @param pCashbalance nuevo Valor de cashbalance
*/
public void setCashbalance(BigDecimal pCashbalance) {
this.cashbalance = pCashbalance;
}
/**
* Obtiene el valor de checkbalance
*
* @return valor de checkbalance
*/
public BigDecimal getCheckbalance() {
return this.checkbalance;
}
/**
* Fija el valor de checkbalance
*
* @param pCheckbalance nuevo Valor de checkbalance
*/
public void setCheckbalance(BigDecimal pCheckbalance) {
this.checkbalance = pCheckbalance;
}
@Override
public boolean equals(Object rhs) {
if (rhs == null) {
return false;
}
if (!(rhs instanceof TgeneTransactionMix)) {
return false;
}
TgeneTransactionMix that = (TgeneTransactionMix) rhs;
if ((this.getPk() == null) || (that.getPk() == null)) {
return false;
}
return (this.getPk().equals(that.getPk()));
}
/**
* Implementaci<63>n del metodo hashCode de la la entidad TgeneTransactionMix
*
* @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<63>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<63>n de la creaci<63>n de un bean en blanco TgeneTransactionMix */
@Override
public Object createInstance() {
TgeneTransactionMix instance = new TgeneTransactionMix();
instance.setPk(new TgeneTransactionMixKey());
return instance;
}
/**
* Clona la entidad TgeneTransactionMix
*
* @see com.fp.dto.hb.HibernateBean#cloneMe()
*/
@Override
public Object cloneMe() throws CloneNotSupportedException {
TgeneTransactionMix p = (TgeneTransactionMix) this.clone();
p.setPk((TgeneTransactionMixKey) this.pk.cloneMe());
return p;
}
// METODOS MANUALES
/** Sentencia que entrega datos de TgeneTransactionMix, para la fecha de tarbajo, usuario y numero de caja multiple. */
private static final String JPQL_TRANS_MIX = " from TgeneTransactionMix tmix" + " where tmix.pk.workingdate = :workingdate "
+ " and tmix.pk.usercode = :user" + " and tmix.pk.mixnumber = :mixnumber ";
/**
* Metodo que entrega un registro de TgeneTransactionMix, dada la fecha de trabajo, codigo de usuario y secuencia de
* caja multiple, que se calcula por fecha de trabajo y usuario.
*
* @param pEntityManager Session de la base de datos.
* @param pWorkingdate Fecha de trabajo.
* @param pUser Codigo de usuario.
* @param pMixnumber Secuencia de caja multiple.
* @return TgeneTransactionMix
* @throws Exception
*/
public static TgeneTransactionMix find(EntityManager pEntityManager, Date pWorkingdate, String pUser, Integer pMixnumber) throws Exception {
Query qry = pEntityManager.createQuery(TgeneTransactionMix.JPQL_TRANS_MIX);
qry.setParameter(Constant.VWORKINGDATE, pWorkingdate);
qry.setParameter("user", pUser);
qry.setParameter("mixnumber", pMixnumber);
try {
return (TgeneTransactionMix) qry.getSingleResult();
} catch (NoResultException e) {
return null;
}
}
}