Skip to content

Commit

Permalink
BugID: 539 - Controllo della Spesa - spostato controllo e aggiornamen…
Browse files Browse the repository at this point in the history
…to in fase di proposta def + Consultazione limiti per uo
  • Loading branch information
rpucciarelli committed Mar 1, 2011
1 parent 66456d6 commit eda2a93
Show file tree
Hide file tree
Showing 15 changed files with 614 additions and 116 deletions.
@@ -0,0 +1,88 @@
/*
* Created by BulkGenerator 2.0 [07/12/2009]
* Date 21/02/2011
*/
package it.cnr.contab.config00.pdcfin.bulk;
import it.cnr.jada.persistency.Keyed;
public class VLimiteSpesaDetBase extends VLimiteSpesaDetKey implements Keyed {

// DS_ELEMENTO_VOCE VARCHAR(100)
private java.lang.String ds_elemento_voce;

// IMPORTO_LIMITE DECIMAL(15,2) NOT NULL
private java.math.BigDecimal importo_limite;

// IMPEGNI_ASSUNTI DECIMAL(15,2) NOT NULL
private java.math.BigDecimal impegni_assunti;

// IMPORTO_DISPONIBILE DECIMAL(22,0)
private java.lang.Long importo_disponibile;

/**
* Created by BulkGenerator 2.0 [07/12/2009]
* Table name: V_LIMITE_SPESA_DET
**/
public VLimiteSpesaDetBase() {
super();
}
public VLimiteSpesaDetBase(java.lang.Integer esercizio, java.lang.String cdCds, java.lang.String tiAppartenenza, java.lang.String tiGestione, java.lang.String cdElementoVoce, java.lang.String fonte) {
super(esercizio, cdCds, tiAppartenenza, tiGestione, cdElementoVoce, fonte);
}

/**
* Created by BulkGenerator 2.0 [07/12/2009]
* Restituisce il valore di: [ds_elemento_voce]
**/
public java.lang.String getDs_elemento_voce() {
return ds_elemento_voce;
}
/**
* Created by BulkGenerator 2.0 [07/12/2009]
* Setta il valore di: [ds_elemento_voce]
**/
public void setDs_elemento_voce(java.lang.String ds_elemento_voce) {
this.ds_elemento_voce=ds_elemento_voce;
}
/**
* Created by BulkGenerator 2.0 [07/12/2009]
* Restituisce il valore di: [importo_limite]
**/
public java.math.BigDecimal getImporto_limite() {
return importo_limite;
}
/**
* Created by BulkGenerator 2.0 [07/12/2009]
* Setta il valore di: [importo_limite]
**/
public void setImporto_limite(java.math.BigDecimal importo_limite) {
this.importo_limite=importo_limite;
}
/**
* Created by BulkGenerator 2.0 [07/12/2009]
* Restituisce il valore di: [impegni_assunti]
**/
public java.math.BigDecimal getImpegni_assunti() {
return impegni_assunti;
}
/**
* Created by BulkGenerator 2.0 [07/12/2009]
* Setta il valore di: [impegni_assunti]
**/
public void setImpegni_assunti(java.math.BigDecimal impegni_assunti) {
this.impegni_assunti=impegni_assunti;
}
/**
* Created by BulkGenerator 2.0 [07/12/2009]
* Restituisce il valore di: [importo_disponibile]
**/
public java.lang.Long getImporto_disponibile() {
return importo_disponibile;
}
/**
* Created by BulkGenerator 2.0 [07/12/2009]
* Setta il valore di: [importo_disponibile]
**/
public void setImporto_disponibile(java.lang.Long importo_disponibile) {
this.importo_disponibile=importo_disponibile;
}
}
@@ -0,0 +1,33 @@
/*
* Created by BulkGenerator 2.0 [07/12/2009]
* Date 21/02/2011
*/
package it.cnr.contab.config00.pdcfin.bulk;
import it.cnr.jada.action.ActionContext;
import it.cnr.jada.bulk.OggettoBulk;
import it.cnr.jada.util.action.CRUDBP;
public class VLimiteSpesaDetBulk extends VLimiteSpesaDetBase {
/**
* Created by BulkGenerator 2.0 [07/12/2009]
* Table name: V_LIMITE_SPESA_DET
**/
public static final java.util.Dictionary fonteKeys = new it.cnr.jada.util.OrderedHashtable();

final public static String FONTE_INTERNA = "FIN";
final public static String FONTE_ESTERNA = "FES";

static {
fonteKeys.put(FONTE_INTERNA,"Interna");
fonteKeys.put(FONTE_ESTERNA,"Esterna");
}
public VLimiteSpesaDetBulk() {
super();
}
/**
* Created by BulkGenerator 2.0 [07/12/2009]
* Table name: V_LIMITE_SPESA_DET
**/
public VLimiteSpesaDetBulk(java.lang.Integer esercizio, java.lang.String cdCds, java.lang.String tiAppartenenza, java.lang.String tiGestione, java.lang.String cdElementoVoce, java.lang.String fonte) {
super(esercizio, cdCds, tiAppartenenza, tiGestione, cdElementoVoce, fonte);
}
}
@@ -0,0 +1,37 @@
/*
* Created by BulkGenerator 2.0 [07/12/2009]
* Date 21/02/2011
*/
package it.cnr.contab.config00.pdcfin.bulk;
import java.sql.Connection;
import java.util.List;

import it.cnr.contab.config00.sto.bulk.Unita_organizzativaBulk;
import it.cnr.contab.config00.sto.bulk.Unita_organizzativa_enteBulk;
import it.cnr.contab.utenze00.bp.CNRUserContext;
import it.cnr.jada.UserContext;
import it.cnr.jada.bulk.BulkHome;
import it.cnr.jada.persistency.PersistencyException;
import it.cnr.jada.persistency.PersistentCache;
import it.cnr.jada.persistency.sql.CompoundFindClause;
import it.cnr.jada.persistency.sql.PersistentHome;
import it.cnr.jada.persistency.sql.SQLBuilder;
public class VLimiteSpesaDetHome extends BulkHome {
public VLimiteSpesaDetHome(Connection conn) {
super(VLimiteSpesaDetBulk.class, conn);
}
public VLimiteSpesaDetHome(Connection conn, PersistentCache persistentCache) {
super(VLimiteSpesaDetBulk.class, conn, persistentCache);
}
public SQLBuilder selectByClause(UserContext usercontext, CompoundFindClause compoundfindclause) throws PersistencyException {
SQLBuilder sql = super.selectByClause(usercontext, compoundfindclause);
sql.addClause("AND","esercizio",SQLBuilder.EQUALS, CNRUserContext.getEsercizio(usercontext));
PersistentHome uoEnteHome = getHomeCache().getHome(Unita_organizzativa_enteBulk.class);
List result = uoEnteHome.fetchAll( uoEnteHome.createSQLBuilder() );
String cdsEnte = ((Unita_organizzativaBulk) result.get(0)).getCd_cds();

if(CNRUserContext.getCd_cds(usercontext).compareTo(cdsEnte)!=0)
sql.addClause("AND","cd_cds",SQLBuilder.EQUALS, CNRUserContext.getCd_cds(usercontext));
return sql;
}
}
@@ -0,0 +1,107 @@
/*
* Created by BulkGenerator 2.0 [07/12/2009]
* Date 21/02/2011
*/
package it.cnr.contab.config00.pdcfin.bulk;
import it.cnr.jada.bulk.OggettoBulk;
import it.cnr.jada.persistency.KeyedPersistent;
public class VLimiteSpesaDetKey extends OggettoBulk implements KeyedPersistent {
/**
* Created by BulkGenerator 2.0 [07/12/2009]
* Table name: V_LIMITE_SPESA_DET
**/
public VLimiteSpesaDetKey() {
super();
}
private java.lang.Integer esercizio;
private java.lang.String cd_cds;
private java.lang.String ti_appartenenza;
private java.lang.String ti_gestione;
private java.lang.String cd_elemento_voce;
private java.lang.String fonte;

public VLimiteSpesaDetKey(java.lang.Integer esercizio, java.lang.String Cd_cds, java.lang.String tiAppartenenza, java.lang.String tiGestione, java.lang.String cdElementoVoce, java.lang.String fonte) {
super();
this.esercizio=esercizio;
this.cd_cds=Cd_cds;
this.ti_appartenenza=tiAppartenenza;
this.ti_gestione=tiGestione;
this.cd_elemento_voce=cdElementoVoce;
this.fonte=fonte;
}
public boolean equalsByPrimaryKey(Object o) {
if (this== o) return true;
if (!(o instanceof VLimiteSpesaDetKey)) return false;
VLimiteSpesaDetKey k = (VLimiteSpesaDetKey) o;
if (!compareKey(getEsercizio(), k.getEsercizio())) return false;
if (!compareKey(getCd_cds(), k.getCd_cds())) return false;
if (!compareKey(getTi_appartenenza(), k.getTi_appartenenza())) return false;
if (!compareKey(getTi_gestione(), k.getTi_gestione())) return false;
if (!compareKey(getCd_elemento_voce(), k.getCd_elemento_voce())) return false;
if (!compareKey(getFonte(), k.getFonte())) return false;
return true;
}
public int primaryKeyHashCode() {
int i = 0;
i = i + calculateKeyHashCode(getEsercizio());
i = i + calculateKeyHashCode(getCd_cds());
i = i + calculateKeyHashCode(getTi_appartenenza());
i = i + calculateKeyHashCode(getTi_gestione());
i = i + calculateKeyHashCode(getCd_elemento_voce());
i = i + calculateKeyHashCode(getFonte());
return i;
}
/**
* Created by BulkGenerator 2.0 [07/12/2009]
* Restituisce il valore di: [esercizio]
**/
public void setEsercizio(java.lang.Integer esercizio) {
this.esercizio=esercizio;
}
/**
* Created by BulkGenerator 2.0 [07/12/2009]
* Setta il valore di: [esercizio]
**/
public java.lang.Integer getEsercizio() {
return esercizio;
}

/**
* Created by BulkGenerator 2.0 [07/12/2009]
* Restituisce il valore di: [fonte]
**/
public void setFonte(java.lang.String fonte) {
this.fonte=fonte;
}
/**
* Created by BulkGenerator 2.0 [07/12/2009]
* Setta il valore di: [fonte]
**/
public java.lang.String getFonte() {
return fonte;
}
public java.lang.String getCd_cds() {
return cd_cds;
}
public void setCd_cds(java.lang.String cd_cds) {
this.cd_cds = cd_cds;
}
public java.lang.String getTi_appartenenza() {
return ti_appartenenza;
}
public void setTi_appartenenza(java.lang.String ti_appartenenza) {
this.ti_appartenenza = ti_appartenenza;
}
public java.lang.String getTi_gestione() {
return ti_gestione;
}
public void setTi_gestione(java.lang.String ti_gestione) {
this.ti_gestione = ti_gestione;
}
public java.lang.String getCd_elemento_voce() {
return cd_elemento_voce;
}
public void setCd_elemento_voce(java.lang.String cd_elemento_voce) {
this.cd_elemento_voce = cd_elemento_voce;
}
}
Expand Up @@ -787,60 +787,7 @@ public Voce_f_saldi_cdr_lineaBulk aggiornaVariazioneStanziamento(UserContext use
saldo.setUser( ((it.cnr.contab.utenze00.bp.CNRUserContext)userContext).getUser());
saldo.setToBeUpdated();
updateBulk( userContext, saldo );
// rospuc 01/2011 inizio modifica da provare controllo della spesa
voce = (Voce_fBulk)getHome(userContext,Voce_fBulk.class).findByPrimaryKey(
new Voce_fBulk(voce.getCd_voce(),voce.getEsercizio(),voce.getTi_appartenenza(),voce.getTi_gestione())
);
Elemento_voceBulk elemento_voce = (Elemento_voceBulk)getHome(userContext,Elemento_voceBulk.class).findByPrimaryKey(
new Elemento_voceBulk(voce.getCd_elemento_voce(),voce.getEsercizio(),voce.getTi_appartenenza(),voce.getTi_gestione())
);
if (elemento_voce == null)
throw new ApplicationException("Elemento voce non trovato per la Voce: "+ voce.getCd_voce());
if(elemento_voce.getFl_limite_spesa().booleanValue()){
WorkpackageBulk workpackage = (WorkpackageBulk)getHome(userContext,WorkpackageBulk.class).findByPrimaryKey(
new WorkpackageBulk(cd_cdr,cd_linea_attivita)
);
LimiteSpesaBulk limiteTestata=(LimiteSpesaBulk)getHome(userContext, LimiteSpesaBulk.class).findByPrimaryKey(
new LimiteSpesaBulk(esercizio_res,voce.getTi_appartenenza(),voce.getTi_gestione(),voce.getCd_elemento_voce(),
((NaturaBulk)getHome(userContext,NaturaBulk.class).findByPrimaryKey(
new NaturaBulk(workpackage.getCd_natura()))).getTipo()));
if(limiteTestata==null)
limiteTestata=(LimiteSpesaBulk)getHome(userContext, LimiteSpesaBulk.class).findByPrimaryKey(
new LimiteSpesaBulk(esercizio_res,voce.getTi_appartenenza(),voce.getTi_gestione(),voce.getCd_elemento_voce(),"*"));
String cds=null;
if (limiteTestata!=null)
{
CdrBulk cdr=(CdrBulk)getHome(userContext, CdrBulk.class).findByPrimaryKey(
new CdrBulk(cd_cdr));
if(cdr.getCd_unita_organizzativa()!=null){
Unita_organizzativaBulk uo=(Unita_organizzativaBulk)getHome(userContext, Unita_organizzativaBulk.class).findByPrimaryKey(
new Unita_organizzativaBulk(cdr.getCd_unita_organizzativa()));
if(uo.getUnita_padre()!=null)
cds=uo.getCd_cds();
}
LimiteSpesaDetBulk limite=(LimiteSpesaDetBulk)getHome(userContext, LimiteSpesaDetBulk.class).findByPrimaryKey(
new LimiteSpesaDetBulk(esercizio_res,cds,voce.getTi_appartenenza(),voce.getTi_gestione(),voce.getCd_elemento_voce(),
((NaturaBulk)getHome(userContext,NaturaBulk.class).findByPrimaryKey(
new NaturaBulk(workpackage.getCd_natura()))).getTipo()));
if(limite==null)
limite=(LimiteSpesaDetBulk)getHome(userContext, LimiteSpesaDetBulk.class).findByPrimaryKey(
new LimiteSpesaDetBulk(esercizio_res,cds,voce.getTi_appartenenza(),voce.getTi_gestione(),voce.getCd_elemento_voce(),"*"));
if(limite==null)
throw new ApplicationException("Limite sul controllo della spesa non definito per il CdS.");
if((limite.getImpegni_assunti().add(importo)).compareTo(limite.getImporto_limite())>0)
throw new ApplicationException("Disponibilità ad impegnare non sufficiente, sulla voce "+elemento_voce.getCd_elemento_voce()+", residuo "+limite.getImporto_limite().subtract(limite.getImpegni_assunti()));
else{
limite.setImpegni_assunti(limite.getImpegni_assunti().add(importo));
limite.setUser( ((it.cnr.contab.utenze00.bp.CNRUserContext)userContext).getUser());
limite.setToBeUpdated();
updateBulk( userContext, limite );
}
}
// Presupponiamo che se non è in testata non è soggetta ai limite(per evitare di inserire dei limiti fittizzi per le fonte esterne)
//else
//throw new ApplicationException("Limite sul controllo della spesa non definito.");
}
//fine modifica

/**
* @author mspasiano
* Aggiorno i saldi negli anni successivi aperti
Expand Down
Expand Up @@ -524,9 +524,12 @@ private boolean isStatoPdgValidoPerModificaCDP(Pdg_preventivoBulk pdg) {
pdg.getStato().equalsIgnoreCase(pdg.ST_E_CHIUSO);
}
private boolean isStatoPdgPValidoPerModificaCDP(Pdg_esercizioBulk pdgP) {
if (pdgP==null)
return false;
else
return
pdgP.getStato().equalsIgnoreCase(pdgP.STATO_APERTURA_CDR) ||
pdgP.getStato().equalsIgnoreCase(pdgP.STATO_ESAMINATO_CDR);
(pdgP.getStato().equalsIgnoreCase(pdgP.STATO_APERTURA_CDR) ||
pdgP.getStato().equalsIgnoreCase(pdgP.STATO_ESAMINATO_CDR));
}
/**
* Default
Expand Down

0 comments on commit eda2a93

Please sign in to comment.