332 lines
9.0 KiB
Plaintext
Executable File
332 lines
9.0 KiB
Plaintext
Executable File
package com.fp.persistence.pgeneral.charge;
|
||
|
||
import javax.persistence.EmbeddedId;
|
||
import javax.persistence.Entity;
|
||
import javax.persistence.Column;
|
||
import javax.persistence.EntityManager;
|
||
import javax.persistence.NoResultException;
|
||
import javax.persistence.Query;
|
||
|
||
import java.io.Serializable;
|
||
import java.math.BigDecimal;
|
||
import javax.persistence.Table;
|
||
import com.fp.dto.hb.HibernateBean;
|
||
import java.lang.reflect.Field;
|
||
import javax.persistence.Transient;
|
||
|
||
/** Clase que implementa la entidad de Hibernate que hace referencia a la tabla TGENECHARGESGROUP */
|
||
@Entity(name = "TgeneChargesGroup")
|
||
@Table(name = "TGENECHARGESGROUP")
|
||
public class TgeneChargesGroup 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 TgeneChargesGroup
|
||
*/
|
||
@EmbeddedId
|
||
private TgeneChargesGroupKey pk;
|
||
@Column(name = "CHARGECURRENCYCODE", nullable = true)
|
||
/**
|
||
* Codigo de moneda en la que esta expresado el cargo
|
||
*/
|
||
private String chargecurrencycode;
|
||
|
||
@Column(name = "RATE", nullable = true)
|
||
/**
|
||
* Tasa anual a aplicar
|
||
*/
|
||
private BigDecimal rate;
|
||
|
||
@Column(name = "PERCENT", nullable = true)
|
||
/**
|
||
* Porcentaje flat a aplicar
|
||
*/
|
||
private BigDecimal percent;
|
||
|
||
@Column(name = "MINVALUE", nullable = true)
|
||
/**
|
||
* Valor minimo a cobrar
|
||
*/
|
||
private BigDecimal minvalue;
|
||
|
||
@Column(name = "MAXVALUE", nullable = true)
|
||
/**
|
||
* Valor maximo a cobrar
|
||
*/
|
||
private BigDecimal maxvalue;
|
||
|
||
@Column(name = "MAXAMOUNT", nullable = true)
|
||
/**
|
||
* Monto maximo para buscar el cargo
|
||
*/
|
||
private BigDecimal maxamount;
|
||
|
||
/** Contructor por defecto */
|
||
public TgeneChargesGroup() {
|
||
}
|
||
/**
|
||
* Contructor de TgeneChargesGroup
|
||
*
|
||
* @param pPk Clave Primaria del entity
|
||
*/
|
||
public TgeneChargesGroup(TgeneChargesGroupKey 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 TgeneChargesGroup
|
||
*/
|
||
public static TgeneChargesGroup find(EntityManager pEntityManager, TgeneChargesGroupKey pKey) throws Exception {
|
||
TgeneChargesGroup obj = pEntityManager.find(TgeneChargesGroup.class, pKey);
|
||
return obj;
|
||
}
|
||
/**
|
||
* Entrega la Clave primaria de TgeneChargesGroup
|
||
*
|
||
* @return El objeto que referencia a la Clave primaria de TgeneChargesGroup
|
||
*/
|
||
public TgeneChargesGroupKey getPk() {
|
||
return pk;
|
||
}
|
||
/**
|
||
* Fija un nuevo valor a la Clave primaria de TgeneChargesGroup
|
||
*
|
||
* @param pPk El objeto que referencia a la nueva Clave primaria de TgeneChargesGroup
|
||
*/
|
||
public void setPk(TgeneChargesGroupKey pPk) {
|
||
pk = pPk;
|
||
}
|
||
/**
|
||
* Obtiene el valor de chargecurrencycode
|
||
*
|
||
* @return valor de chargecurrencycode
|
||
*/
|
||
public String getChargecurrencycode() {
|
||
return chargecurrencycode;
|
||
}
|
||
/**
|
||
* Fija el valor de chargecurrencycode
|
||
*
|
||
* @param pChargecurrencycode nuevo Valor de chargecurrencycode
|
||
*/
|
||
public void setChargecurrencycode(String pChargecurrencycode) {
|
||
chargecurrencycode = pChargecurrencycode;
|
||
}
|
||
|
||
/**
|
||
* Obtiene el valor de rate
|
||
*
|
||
* @return valor de rate
|
||
*/
|
||
public BigDecimal getRate() {
|
||
return rate;
|
||
}
|
||
/**
|
||
* Fija el valor de rate
|
||
*
|
||
* @param pRate nuevo Valor de rate
|
||
*/
|
||
public void setRate(BigDecimal pRate) {
|
||
rate = pRate;
|
||
}
|
||
|
||
/**
|
||
* Obtiene el valor de percent
|
||
*
|
||
* @return valor de percent
|
||
*/
|
||
public BigDecimal getPercent() {
|
||
return percent;
|
||
}
|
||
/**
|
||
* Fija el valor de percent
|
||
*
|
||
* @param pPercent nuevo Valor de percent
|
||
*/
|
||
public void setPercent(BigDecimal pPercent) {
|
||
percent = pPercent;
|
||
}
|
||
|
||
/**
|
||
* Obtiene el valor de minvalue
|
||
*
|
||
* @return valor de minvalue
|
||
*/
|
||
public BigDecimal getMinvalue() {
|
||
return minvalue;
|
||
}
|
||
/**
|
||
* Fija el valor de minvalue
|
||
*
|
||
* @param pMinvalue nuevo Valor de minvalue
|
||
*/
|
||
public void setMinvalue(BigDecimal pMinvalue) {
|
||
minvalue = pMinvalue;
|
||
}
|
||
|
||
/**
|
||
* Obtiene el valor de maxvalue
|
||
*
|
||
* @return valor de maxvalue
|
||
*/
|
||
public BigDecimal getMaxvalue() {
|
||
return maxvalue;
|
||
}
|
||
/**
|
||
* Fija el valor de maxvalue
|
||
*
|
||
* @param pMaxvalue nuevo Valor de maxvalue
|
||
*/
|
||
public void setMaxvalue(BigDecimal pMaxvalue) {
|
||
maxvalue = pMaxvalue;
|
||
}
|
||
|
||
/**
|
||
* Obtiene el valor de maxamount
|
||
*
|
||
* @return valor de maxamount
|
||
*/
|
||
public BigDecimal getMaxamount() {
|
||
return maxamount;
|
||
}
|
||
/**
|
||
* Fija el valor de maxamount
|
||
*
|
||
* @param pMaxamount nuevo Valor de maxamount
|
||
*/
|
||
public void setMaxamount(BigDecimal pMaxamount) {
|
||
maxamount = pMaxamount;
|
||
}
|
||
|
||
public boolean equals(Object rhs) {
|
||
if (rhs == null)
|
||
return false;
|
||
if (!(rhs instanceof TgeneChargesGroup))
|
||
return false;
|
||
TgeneChargesGroup that = (TgeneChargesGroup) 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 TgeneChargesGroup
|
||
*
|
||
* @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<63>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<63>n de la creaci<63>n de un bean en blanco TgeneChargesGroup */
|
||
public Object createInstance() {
|
||
TgeneChargesGroup instance = new TgeneChargesGroup();
|
||
instance.setPk(new TgeneChargesGroupKey());
|
||
return instance;
|
||
}
|
||
/**
|
||
* Clona la entidad TgeneChargesGroup
|
||
*
|
||
* @see com.fp.dto.hb.HibernateBean#cloneMe()
|
||
*/
|
||
public Object cloneMe() throws CloneNotSupportedException {
|
||
TgeneChargesGroup p = (TgeneChargesGroup) this.clone();
|
||
p.setPk((TgeneChargesGroupKey) this.pk.cloneMe());
|
||
return p;
|
||
}
|
||
|
||
//Metodos manuales.
|
||
/** Sentencia que devuelve un registro de TgeneChargesGroup.*/
|
||
private static final String HQL_CHARGES_GROUP =
|
||
"from TgeneChargesGroup tchargrp " +
|
||
" where tchargrp.pk.catalog = :catalog " +
|
||
" and tchargrp.pk.catalogcode = :catalogcode "+
|
||
" and tchargrp.pk.balancetype = :balancetype "+
|
||
" and tchargrp.pk.balancegroup = :balancegroup "+
|
||
" and tchargrp.pk.modulecode = :modulecode "+
|
||
" and tchargrp.pk.statuscode = :statuscode "+
|
||
" and tchargrp.pk.companycode = :companycode "+
|
||
" and tchargrp.pk.currencycode = :currencycode "+
|
||
" and :amount between tchargrp.pk.minamount and tchargrp.maxamount ";
|
||
|
||
|
||
/**
|
||
* Metodo que entrega la definicion de cargos de grupos de clientes.
|
||
* @param pCatalog Codigo de aagrupacion de cargos, Empleados, Clientes vip
|
||
* @param pCatalogCode Codigo de catalogo de agrupacion de cargos (CHARGES)
|
||
* @param pBalanceType Codigo de tipo de saldo a entregar buscar cargo.
|
||
* @param pBanceGroup Codigo de tipo grupo de balance a entregar buscar cargo.
|
||
* @param pModuleCode Codigo de modulo asociado al estatus de la cuenta a buscar el cargo.
|
||
* @param pStatusCode Codigo de estatus de la cuenta a buscar el saldo.
|
||
* @param pCompany Codigo de compania de la cuenta a buscar le cargo.
|
||
* @param pCurrency Codigo de moneda de la cuenta a buscar le cargo.
|
||
* @param pAmount Monto base con el cual se obtiene el cargo.
|
||
* @return TgeneChargesGroup
|
||
* @throws Exception
|
||
*/
|
||
public static TgeneChargesGroup find(EntityManager pEntityManager,String pCatalog,String pCatalogCode,String pBalanceType,
|
||
String pBanceGroup,String pModuleCode,String pStatusCode,Integer pCompany,String pCurrency,BigDecimal pAmount) throws Exception {
|
||
TgeneChargesGroup obj = null;
|
||
Query qry = pEntityManager.createQuery(HQL_CHARGES_GROUP);
|
||
qry.setParameter("catalog", pCatalog);
|
||
qry.setParameter("catalogcode", pCatalog);
|
||
qry.setParameter("balancetype", pCatalog);
|
||
qry.setParameter("balancegroup", pCatalog);
|
||
qry.setParameter("modulecode", pCatalog);
|
||
qry.setParameter("statuscode", pCatalog);
|
||
qry.setParameter("companycode", pCatalog);
|
||
qry.setParameter("currencycode", pCatalog);
|
||
qry.setParameter("amount", pCatalog);
|
||
try {
|
||
obj = (TgeneChargesGroup)qry.getSingleResult();
|
||
} catch (NoResultException e) {
|
||
return obj;
|
||
}
|
||
return obj;
|
||
}
|
||
|
||
}
|