Skip to content

Commit

Permalink
Fix Variazioni Bilancio Residuo: corretta controllo su disponibilità …
Browse files Browse the repository at this point in the history
…Piano Economico Progetto.
  • Loading branch information
raffaelepagano committed Jan 22, 2020
1 parent e3af1ed commit d227d80
Show file tree
Hide file tree
Showing 10 changed files with 2,561 additions and 2,364 deletions.
514 changes: 318 additions & 196 deletions sigla-ejb/src/main/java/it/cnr/contab/doccont00/comp/SaldoComponent.java

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Expand Up @@ -635,7 +635,7 @@ public SQLBuilder selectElemento_voceByClause (UserContext userContext,
//Recupero la lista delle voci movimentate perchè se tra quelle da eliminare occorre comunque selezionarle per consentire
//all'utente di effettuare una variazione negativa
List<V_saldi_voce_progettoBulk> vociMovimentate = ((V_saldi_voce_progettoHome)getHome(userContext, V_saldi_voce_progettoBulk.class))
.cercaSaldoVoce(progetto.getPg_progetto(),progetto.getEsercizio()).stream()
.cercaSaldoVoce(progetto.getPg_progetto()).stream()
.filter(el->el.getAssestato().compareTo(BigDecimal.ZERO)>0 ||
el.getUtilizzatoAssestatoFinanziamento().compareTo(BigDecimal.ZERO)>0)
.collect(Collectors.toList());
Expand Down
1,977 changes: 1,008 additions & 969 deletions sigla-ejb/src/main/java/it/cnr/contab/progettiric00/core/bulk/ProgettoHome.java

Large diffs are not rendered by default.

Expand Up @@ -78,9 +78,8 @@ public SQLBuilder selectProgettoPianoEconomicoList( java.lang.Integer esercizio,
sqlExists.addSQLJoin("ASS_PROGETTO_PIAECO_VOCE.CD_UNITA_ORGANIZZATIVA", "PROGETTO_PIANO_ECONOMICO.CD_UNITA_ORGANIZZATIVA");
sqlExists.addSQLJoin("ASS_PROGETTO_PIAECO_VOCE.CD_VOCE_PIANO", "PROGETTO_PIANO_ECONOMICO.CD_VOCE_PIANO");
sqlExists.addSQLJoin("ASS_PROGETTO_PIAECO_VOCE.ESERCIZIO_PIANO", "PROGETTO_PIANO_ECONOMICO.ESERCIZIO_PIANO");
sqlExists.addSQLClause(FindClause.AND, "ASS_PROGETTO_PIAECO_VOCE.ESERCIZIO_VOCE", SQLBuilder.EQUALS, esercizio);
sqlExists.addSQLClause(FindClause.AND, "ASS_PROGETTO_PIAECO_VOCE.PG_PROGETTO", SQLBuilder.EQUALS, pgProgetto);
sqlExists.addSQLClause(FindClause.AND, "ASS_PROGETTO_PIAECO_VOCE.ESERCIZIO_VOCE", SQLBuilder.EQUALS, elementoVoce.getEsercizio());
sqlExists.addSQLClause(FindClause.AND, "ASS_PROGETTO_PIAECO_VOCE.ESERCIZIO_VOCE", SQLBuilder.EQUALS, esercizio);
sqlExists.addSQLClause(FindClause.AND, "ASS_PROGETTO_PIAECO_VOCE.TI_APPARTENENZA", SQLBuilder.EQUALS, elementoVoce.getTi_appartenenza());
sqlExists.addSQLClause(FindClause.AND, "ASS_PROGETTO_PIAECO_VOCE.TI_GESTIONE", SQLBuilder.EQUALS, elementoVoce.getTi_gestione());
sqlExists.addSQLClause(FindClause.AND, "ASS_PROGETTO_PIAECO_VOCE.CD_ELEMENTO_VOCE", SQLBuilder.EQUALS, elementoVoce.getCd_elemento_voce());
Expand Down
Expand Up @@ -22,8 +22,11 @@
* Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
*/
package it.cnr.contab.progettiric00.core.bulk;
import java.math.BigDecimal;
import java.util.List;

import it.cnr.contab.config00.bulk.Configurazione_cnrBulk;
import it.cnr.contab.config00.bulk.Configurazione_cnrHome;
import it.cnr.jada.bulk.BulkHome;
import it.cnr.jada.persistency.PersistencyException;
import it.cnr.jada.persistency.PersistentCache;
Expand Down Expand Up @@ -64,12 +67,16 @@ public V_saldi_voce_progettoBulk cercaSaldoVoce(Ass_progetto_piaeco_voceBulk bul
return null;
}

public List<V_saldi_voce_progettoBulk> cercaSaldoVoce(Integer pgProgetto, Integer esercizio) throws PersistencyException
public List<V_saldi_voce_progettoBulk> cercaSaldoVoce(Integer pgProgetto) throws PersistencyException
{
SQLBuilder sql = this.createSQLBuilder();

SQLBuilder sql = this.createSQLBuilder();

BigDecimal annoFrom = ((Configurazione_cnrHome)getHomeCache().getHome(Configurazione_cnrBulk.class))
.getConfigurazione(new Integer(0), null, Configurazione_cnrBulk.PK_GESTIONE_PROGETTI, Configurazione_cnrBulk.SK_PROGETTO_PIANO_ECONOMICO)
.getIm01();

sql.addSQLClause(FindClause.AND,"PG_PROGETTO",SQLBuilder.EQUALS,pgProgetto);
sql.addSQLClause(FindClause.AND,"ESERCIZIO",SQLBuilder.EQUALS,esercizio);
sql.addSQLClause(FindClause.AND,"ESERCIZIO",SQLBuilder.GREATER_EQUALS,annoFrom);

return fetchAll(sql);
}
Expand Down
@@ -1,96 +1,96 @@
/*
* Copyright (C) 2019 Consiglio Nazionale delle Ricerche
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

/*
* Created by Generator 1.0
* Date 15/02/2006
*/
package it.cnr.contab.varstanz00.bulk;
import it.cnr.contab.utenze00.bp.CNRUserContext;
import it.cnr.jada.bulk.BulkHome;
import it.cnr.jada.bulk.OggettoBulk;
import it.cnr.jada.comp.ApplicationException;
import it.cnr.jada.persistency.IntrospectionException;
import it.cnr.jada.persistency.PersistencyException;
import it.cnr.jada.persistency.PersistentCache;
import it.cnr.jada.persistency.sql.PersistentHome;
import it.cnr.jada.persistency.sql.SQLBuilder;
public class Var_stanz_resHome extends BulkHome {
public Var_stanz_resHome(java.sql.Connection conn) {
super(Var_stanz_resBulk.class, conn);
}
public Var_stanz_resHome(java.sql.Connection conn, PersistentCache persistentCache) {
super(Var_stanz_resBulk.class, conn, persistentCache);
}
public void initializePrimaryKeyForInsert(it.cnr.jada.UserContext userContext,OggettoBulk var_stanz_res) throws PersistencyException,ApplicationException {
try {
it.cnr.contab.config00.tabnum.ejb.Numerazione_baseComponentSession numerazione =
(it.cnr.contab.config00.tabnum.ejb.Numerazione_baseComponentSession)
it.cnr.jada.util.ejb.EJBCommonServices.createEJB("CNRCONFIG00_TABNUM_EJB_Numerazione_baseComponentSession",
it.cnr.contab.config00.tabnum.ejb.Numerazione_baseComponentSession.class);
if (((Var_stanz_resBulk)var_stanz_res).getPg_variazione()==null) {
if (!userContext.isTransactional())
((Var_stanz_resBulk)var_stanz_res).setPg_variazione(
numerazione.creaNuovoProgressivo(userContext,CNRUserContext.getEsercizio(userContext), "VAR_STANZ_RES", "PG_VARIAZIONE", CNRUserContext.getUser(userContext))
);
else
((Var_stanz_resBulk)var_stanz_res).setPg_variazione(
numerazione.creaNuovoProgressivoTemp(userContext,CNRUserContext.getEsercizio(userContext), "VAR_STANZ_RES", "PG_VARIAZIONE", CNRUserContext.getUser(userContext))
);
}
((Var_stanz_resBulk)var_stanz_res).setEsercizio(CNRUserContext.getEsercizio(userContext));
}catch(it.cnr.jada.bulk.BusyResourceException e) {
throw new ApplicationException(e);
}catch(Throwable e) {
throw new PersistencyException(e);
}
}
/**
* Recupera tutti i dati nella tabella ASS_VAR_STANZ_RES_CDR relativi alla testata in uso.
*
* @param testata La testata in uso.
*
* @return java.util.Collection Collezione di oggetti <code>Ass_pdg_variazione_cdrBulk</code>
*/

public java.util.Collection findAssociazioneCDR(Var_stanz_resBulk testata) throws IntrospectionException, PersistencyException {
PersistentHome dettHome = getHomeCache().getHome(Ass_var_stanz_res_cdrBulk.class);
SQLBuilder sql = dettHome.createSQLBuilder();
sql.addClause("AND","esercizio",sql.EQUALS,testata.getEsercizio());
sql.addClause("AND","pg_variazione",sql.EQUALS,testata.getPg_variazione());
sql.addOrderBy("CD_CENTRO_RESPONSABILITA");
return dettHome.fetchAll(sql);
}

public java.util.Collection findVariazioniRiga(Var_stanz_resBulk testata) throws IntrospectionException, PersistencyException {
PersistentHome dettHome = getHomeCache().getHome(Var_stanz_res_rigaBulk.class);
SQLBuilder sql = dettHome.createSQLBuilder();
sql.addClause("AND","esercizio",sql.EQUALS,testata.getEsercizio());
sql.addClause("AND","pg_variazione",sql.EQUALS,testata.getPg_variazione());
sql.addClause("AND","cd_cdr",sql.EQUALS,testata.getCdr()!=null?testata.getCdr().getCd_centro_responsabilita():null);
return dettHome.fetchAll(sql);
}
public java.util.Collection findAllVariazioniRiga(Var_stanz_resBulk testata) throws IntrospectionException, PersistencyException {
PersistentHome dettHome = getHomeCache().getHome(Var_stanz_res_rigaBulk.class);
SQLBuilder sql = dettHome.createSQLBuilder();
sql.addClause("AND","esercizio",sql.EQUALS,testata.getEsercizio());
sql.addClause("AND","pg_variazione",sql.EQUALS,testata.getPg_variazione());
return dettHome.fetchAll(sql);
}


/*
* Copyright (C) 2019 Consiglio Nazionale delle Ricerche
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

/*
* Created by Generator 1.0
* Date 15/02/2006
*/
package it.cnr.contab.varstanz00.bulk;
import it.cnr.contab.utenze00.bp.CNRUserContext;
import it.cnr.jada.bulk.BulkHome;
import it.cnr.jada.bulk.OggettoBulk;
import it.cnr.jada.comp.ApplicationException;
import it.cnr.jada.persistency.IntrospectionException;
import it.cnr.jada.persistency.PersistencyException;
import it.cnr.jada.persistency.PersistentCache;
import it.cnr.jada.persistency.sql.PersistentHome;
import it.cnr.jada.persistency.sql.SQLBuilder;
public class Var_stanz_resHome extends BulkHome {
public Var_stanz_resHome(java.sql.Connection conn) {
super(Var_stanz_resBulk.class, conn);
}
public Var_stanz_resHome(java.sql.Connection conn, PersistentCache persistentCache) {
super(Var_stanz_resBulk.class, conn, persistentCache);
}
public void initializePrimaryKeyForInsert(it.cnr.jada.UserContext userContext,OggettoBulk var_stanz_res) throws PersistencyException,ApplicationException {
try {
it.cnr.contab.config00.tabnum.ejb.Numerazione_baseComponentSession numerazione =
(it.cnr.contab.config00.tabnum.ejb.Numerazione_baseComponentSession)
it.cnr.jada.util.ejb.EJBCommonServices.createEJB("CNRCONFIG00_TABNUM_EJB_Numerazione_baseComponentSession",
it.cnr.contab.config00.tabnum.ejb.Numerazione_baseComponentSession.class);
if (((Var_stanz_resBulk)var_stanz_res).getPg_variazione()==null) {
if (!userContext.isTransactional())
((Var_stanz_resBulk)var_stanz_res).setPg_variazione(
numerazione.creaNuovoProgressivo(userContext,CNRUserContext.getEsercizio(userContext), "VAR_STANZ_RES", "PG_VARIAZIONE", CNRUserContext.getUser(userContext))
);
else
((Var_stanz_resBulk)var_stanz_res).setPg_variazione(
numerazione.creaNuovoProgressivoTemp(userContext,CNRUserContext.getEsercizio(userContext), "VAR_STANZ_RES", "PG_VARIAZIONE", CNRUserContext.getUser(userContext))
);
}
((Var_stanz_resBulk)var_stanz_res).setEsercizio(CNRUserContext.getEsercizio(userContext));
}catch(it.cnr.jada.bulk.BusyResourceException e) {
throw new ApplicationException(e);
}catch(Throwable e) {
throw new PersistencyException(e);
}
}
/**
* Recupera tutti i dati nella tabella ASS_VAR_STANZ_RES_CDR relativi alla testata in uso.
*
* @param testata La testata in uso.
*
* @return java.util.Collection Collezione di oggetti <code>Ass_pdg_variazione_cdrBulk</code>
*/

public java.util.Collection findAssociazioneCDR(Var_stanz_resBulk testata) throws PersistencyException {
PersistentHome dettHome = getHomeCache().getHome(Ass_var_stanz_res_cdrBulk.class);
SQLBuilder sql = dettHome.createSQLBuilder();
sql.addClause("AND","esercizio",sql.EQUALS,testata.getEsercizio());
sql.addClause("AND","pg_variazione",sql.EQUALS,testata.getPg_variazione());
sql.addOrderBy("CD_CENTRO_RESPONSABILITA");
return dettHome.fetchAll(sql);
}

public java.util.Collection findVariazioniRiga(Var_stanz_resBulk testata) throws PersistencyException {
PersistentHome dettHome = getHomeCache().getHome(Var_stanz_res_rigaBulk.class);
SQLBuilder sql = dettHome.createSQLBuilder();
sql.addClause("AND","esercizio",sql.EQUALS,testata.getEsercizio());
sql.addClause("AND","pg_variazione",sql.EQUALS,testata.getPg_variazione());
sql.addClause("AND","cd_cdr",sql.EQUALS,testata.getCdr()!=null?testata.getCdr().getCd_centro_responsabilita():null);
return dettHome.fetchAll(sql);
}
public java.util.Collection findAllVariazioniRiga(Var_stanz_resBulk testata) throws PersistencyException {
PersistentHome dettHome = getHomeCache().getHome(Var_stanz_res_rigaBulk.class);
SQLBuilder sql = dettHome.createSQLBuilder();
sql.addClause("AND","esercizio",sql.EQUALS,testata.getEsercizio());
sql.addClause("AND","pg_variazione",sql.EQUALS,testata.getPg_variazione());
return dettHome.fetchAll(sql);
}


}
Expand Up @@ -72,6 +72,7 @@
import it.cnr.contab.doccont00.core.bulk.Accertamento_modificaBulk;
import it.cnr.contab.doccont00.core.bulk.ObbligazioneBulk;
import it.cnr.contab.doccont00.core.bulk.ObbligazioneHome;
import it.cnr.contab.doccont00.ejb.SaldoComponentSession;
import it.cnr.contab.messaggio00.bulk.MessaggioBulk;
import it.cnr.contab.messaggio00.bulk.MessaggioHome;
import it.cnr.contab.pdg00.bulk.Pdg_variazioneBulk;
Expand Down Expand Up @@ -429,7 +430,7 @@ public SQLBuilder selectElemento_voceByClause (UserContext userContext,Var_stanz
//Recupero la lista delle voci movimentate perchè se tra quelle da eliminare occorre comunque selezionarle per consentire
//all'utente di effettuare una variazione negativa
List<V_saldi_voce_progettoBulk> vociMovimentate = ((V_saldi_voce_progettoHome)getHome(userContext, V_saldi_voce_progettoBulk.class))
.cercaSaldoVoce(progetto.getPg_progetto(),progetto.getEsercizio()).stream()
.cercaSaldoVoce(progetto.getPg_progetto()).stream()
.filter(el->el.getAssestato().compareTo(BigDecimal.ZERO)>0 ||
el.getUtilizzatoAssestatoFinanziamento().compareTo(BigDecimal.ZERO)>0)
.collect(Collectors.toList());
Expand Down Expand Up @@ -563,13 +564,15 @@ public it.cnr.jada.bulk.OggettoBulk salvaDefinitivo(UserContext userContext, it.
var_stanz_res.setToBeUpdated();
if (var_stanz_res.getAssociazioneCDR().isEmpty())
throw new ApplicationException("Associare almeno un Centro di Responsabilità alla Variazione.");



controllaRimodulazioneProgetto(userContext,var_stanz_res);

try {
Utility.createSaldoComponentSession().checkPdgPianoEconomico(userContext, var_stanz_res);
SaldoComponentSession saldoComponent = Utility.createSaldoComponentSession();
//Verifico che il tipo di variazione sia consentita
saldoComponent.checkPdgPianoEconomico(userContext, var_stanz_res);
//Verifico che piano economico non si sfondi
saldoComponent.checkDispPianoEconomicoProgetto(userContext, var_stanz_res);
} catch (RemoteException e) {
throw new ComponentException(e);
}
Expand Down Expand Up @@ -794,8 +797,6 @@ else if (varRiga.getIm_variazione().compareTo(Utility.ZERO) > 0)
" diventerebbe negativo ("+new it.cnr.contab.util.EuroFormat().format(saldi.getDispAdImpResiduoImproprio().abs())+")");
}
}
} catch (IntrospectionException e) {
throw new ComponentException(e);
} catch (PersistencyException e) {
throw new ComponentException(e);
}
Expand Down Expand Up @@ -1346,11 +1347,7 @@ public void aggiungiDettaglioVariazione(UserContext usercontext, Var_stanz_resBu

var_stanz_res_riga.setIm_variazione(saldo.getImp_da_assegnare());
Var_stanz_resHome testataHome = (Var_stanz_resHome)getHome(usercontext, Var_stanz_resBulk.class);
try {
var_stanz_res.setRigaVariazione(new it.cnr.jada.bulk.BulkList(testataHome.findVariazioniRiga(var_stanz_res)));
} catch (IntrospectionException e1) {
throw new ComponentException(e1);
}
var_stanz_res.setRigaVariazione(new it.cnr.jada.bulk.BulkList(testataHome.findVariazioniRiga(var_stanz_res)));
try {
var_stanz_res_riga.validate(var_stanz_res_riga);
} catch (ValidationException e) {
Expand Down Expand Up @@ -1534,8 +1531,6 @@ public Var_stanz_res_rigaBulk recuperoRigaLiquidazioneIva(it.cnr.jada.UserContex
return spe_det;
}
}
} catch (IntrospectionException e) {
throw new ComponentException(e);
} catch (RemoteException e) {
throw new ComponentException(e);
} catch (PersistencyException e) {
Expand Down

0 comments on commit d227d80

Please sign in to comment.