Sistemati controlli su anno contabile a cavallo, aggiunga migration per setupGest, importazione Rosso gargano
This commit is contained in:
@@ -19,6 +19,7 @@ import it.integry.ems_model.utility.UtilityDB;
|
|||||||
import it.integry.ems_model.utility.UtilityString;
|
import it.integry.ems_model.utility.UtilityString;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.bouncycastle.its.operator.ITSContentSigner;
|
||||||
import org.springframework.web.context.ContextLoader;
|
import org.springframework.web.context.ContextLoader;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -177,8 +178,11 @@ public abstract class BaseMigration implements MigrationModelInterface {
|
|||||||
executeStatement(dropSql);
|
executeStatement(dropSql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void createSetupQuery(String codQuery, String name, String query, boolean override) throws SQLException, IOException {
|
protected void createSetupQuery(String codQuery, String name, String query, boolean override) throws SQLException, IOException {
|
||||||
|
if (UtilityString.isNullOrEmpty(codQuery)) {
|
||||||
|
executeStatement(Query.format("EXEC sp_insertQuerySetup %s", query));
|
||||||
|
return;
|
||||||
|
}
|
||||||
boolean existQuery = false;
|
boolean existQuery = false;
|
||||||
if(override) {
|
if(override) {
|
||||||
String sql = Query.format("SELECT cast(count(*) as bit) FROM stb_gest_setup_query WHERE cod_query = %s", codQuery);
|
String sql = Query.format("SELECT cast(count(*) as bit) FROM stb_gest_setup_query WHERE cod_query = %s", codQuery);
|
||||||
@@ -261,12 +265,26 @@ public abstract class BaseMigration implements MigrationModelInterface {
|
|||||||
ps.executeUpdate();
|
ps.executeUpdate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void createSetup(String gestName, String section, String keySection, String value, String description, boolean flagSync,
|
protected void createSetup(String gestName, String section, String keySection, String value, String description, boolean flagSync,
|
||||||
String codQuery, boolean flagUserView, boolean flagSetupDepo, boolean flagSetupUserWeb,
|
String codQuery, boolean flagUserView, boolean flagSetupDepo, boolean flagSetupUserWeb,
|
||||||
boolean flagTipoJson, boolean flagTipoColore, String tipoSetup, boolean flagMultiValue ) throws Exception {
|
boolean flagTipoJson, boolean flagTipoColore, String tipoSetup, boolean flagMultiValue ) throws Exception {
|
||||||
|
createSetup(gestName, section,keySection, value, description, flagSync, codQuery, flagUserView, flagSetupDepo,
|
||||||
|
flagSetupUserWeb, flagTipoJson, flagTipoColore, tipoSetup, flagMultiValue, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void createSetup(String gestName, String section, String keySection, String value, String description, boolean flagSync,
|
||||||
|
String codQuery, boolean flagUserView, boolean flagSetupDepo, boolean flagSetupUserWeb,
|
||||||
|
boolean flagTipoJson, boolean flagTipoColore, String tipoSetup, boolean flagMultiValue,
|
||||||
|
String query) throws Exception {
|
||||||
if (existsSetup(gestName, section, keySection))
|
if (existsSetup(gestName, section, keySection))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (!UtilityString.isNullOrEmpty(query) && UtilityString.isNullOrEmpty(codQuery)) {
|
||||||
|
codQuery = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(),
|
||||||
|
Query.format("SELECT cod_query FROM stb_gest_setup_query WHERE cod_query = %s", query));
|
||||||
|
}
|
||||||
|
|
||||||
String insertSql = "INSERT INTO " + StbGestSetup.ENTITY +
|
String insertSql = "INSERT INTO " + StbGestSetup.ENTITY +
|
||||||
" (gest_name, section, key_section, value, description, flag_sync, query_default,\n" +
|
" (gest_name, section, key_section, value, description, flag_sync, query_default,\n" +
|
||||||
"flag_user_view, flag_setup_depo, flag_setup_user_web,\n" +
|
"flag_user_view, flag_setup_depo, flag_setup_user_web,\n" +
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
|
||||||
|
public class Migration_20240409163647 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
|
||||||
|
createOrUpdateView("[cvw_saldiContAnno]", "CREATE view [dbo].[cvw_saldiContAnno] as \n" +
|
||||||
|
"select cod_ccon, anno_comp, SUM(saldo_iniz) as saldo_iniz, SUM(dare) as dare, SUM(avere) as avere\n" +
|
||||||
|
"from (\n" +
|
||||||
|
"SELECT ctb_movr.cod_ccon, ctb_movt.anno_comp, 0 AS saldo_iniz, SUM(imp_dare) AS dare, SUM(imp_avere) AS avere\n" +
|
||||||
|
"FROM ctb_cont,\n" +
|
||||||
|
" ctb_caus,\n" +
|
||||||
|
" ctb_movr,\n" +
|
||||||
|
" ctb_movt\n" +
|
||||||
|
"WHERE (ctb_caus.cod_ccau = ctb_movr.cod_ccau)\n" +
|
||||||
|
" AND (ctb_cont.cod_ccon = ctb_movr.cod_ccon)\n" +
|
||||||
|
" AND (ctb_movt.num_cmov = ctb_movr.num_cmov)\n" +
|
||||||
|
" AND ((ctb_caus.flag_ap_ch <> 'A' AND ctb_caus.flag_ap_ch <> 'F'))\n" +
|
||||||
|
"GROUP BY ctb_movr.cod_ccon, ctb_movt.anno_comp\n" +
|
||||||
|
"UNION\n" +
|
||||||
|
"SELECT ctb_movr.cod_ccon, ctb_movt.anno_comp, SUM(imp_dare - imp_avere) AS saldo_iniz, 0 AS dare, 0 AS avere\n" +
|
||||||
|
"FROM ctb_cont,\n" +
|
||||||
|
" ctb_caus,\n" +
|
||||||
|
" ctb_movr,\n" +
|
||||||
|
" ctb_movt\n" +
|
||||||
|
"WHERE (ctb_caus.cod_ccau = ctb_movr.cod_ccau)\n" +
|
||||||
|
" AND (ctb_cont.cod_ccon = ctb_movr.cod_ccon)\n" +
|
||||||
|
" AND (ctb_movt.num_cmov = ctb_movr.num_cmov)\n" +
|
||||||
|
" AND ((ctb_caus.flag_ap_ch = 'A'))\n" +
|
||||||
|
"GROUP BY ctb_movr.cod_ccon, ctb_movt.anno_comp) t\n" +
|
||||||
|
"GROUP BY cod_ccon, anno_comp");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
|
||||||
|
public class Migration_20240409165638 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
|
||||||
|
createOrUpdateView("[cvw_mov_black_list]", "CREATE VIEW cvw_mov_black_list AS\n" +
|
||||||
|
"SELECT crl_movt_rif_cmov.num_cmov, \n" +
|
||||||
|
" ctb_movt.num_cmov as num_cmov_rif,\n" +
|
||||||
|
" ctb_movt.data_cmov, \n" +
|
||||||
|
" ctb_movt.cod_ccau, \n" +
|
||||||
|
" ctb_movt.cod_anag, \n" +
|
||||||
|
" gtb_anag.rag_soc,\n" +
|
||||||
|
" ctb_movt.data_doc, \n" +
|
||||||
|
" ctb_movt.ser_doc, \n" +
|
||||||
|
" ctb_movt.num_doc,\n" +
|
||||||
|
" ctb_movt.importo\n" +
|
||||||
|
"FROM crl_movt_rif_cmov, ctb_movt, gtb_anag\n" +
|
||||||
|
"WHERE crl_movt_rif_cmov.num_cmov_rif = ctb_movt.num_cmov AND \n" +
|
||||||
|
" ctb_movt.cod_anag = gtb_anag.cod_anag");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -20,6 +20,8 @@ import java.util.*;
|
|||||||
|
|
||||||
|
|
||||||
public class AccountingRules extends QueryRules {
|
public class AccountingRules extends QueryRules {
|
||||||
|
|
||||||
|
|
||||||
public static Integer completeNumIreg(Connection connection, String codIreg) throws Exception {
|
public static Integer completeNumIreg(Connection connection, String codIreg) throws Exception {
|
||||||
String sql =
|
String sql =
|
||||||
"SELECT min(num_ireg) as min FROM ctb_inum WHERE cod_ireg = " + UtilityDB.valueToString(codIreg);
|
"SELECT min(num_ireg) as min FROM ctb_inum WHERE cod_ireg = " + UtilityDB.valueToString(codIreg);
|
||||||
@@ -118,19 +120,16 @@ public class AccountingRules extends QueryRules {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static Integer completeAnnoComp(Connection conn, Date dataCmov) throws SQLException {
|
public static Integer getAnnoComp(Connection conn, Date dataCmov) throws SQLException {
|
||||||
if (dataCmov == null) {
|
if (dataCmov == null)
|
||||||
SimpleDateFormat formatDate = new SimpleDateFormat("yyyy");
|
return UtilityLocalDate.getNow().getYear();
|
||||||
Date now = new Date();
|
|
||||||
return Integer.valueOf(formatDate.format(now));
|
|
||||||
}
|
|
||||||
String sql =
|
String sql =
|
||||||
Query.format(
|
Query.format(
|
||||||
"SELECT anno FROM gtb_periodo_fisc WHERE %s BETWEEN data_iniz AND data_fine",
|
"SELECT dbo.f_getAnnoFisc(%s)",
|
||||||
dataCmov );
|
dataCmov );
|
||||||
|
|
||||||
Short annoComp = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
|
return UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
|
||||||
return annoComp.intValue();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getCodBiva(Connection connection, String codAnag) throws Exception {
|
public static String getCodBiva(Connection connection, String codAnag) throws Exception {
|
||||||
|
|||||||
@@ -7,10 +7,7 @@ import it.integry.ems_model.entity.DtbDocr;
|
|||||||
import it.integry.ems_model.entity.DtbDoct;
|
import it.integry.ems_model.entity.DtbDoct;
|
||||||
import it.integry.ems_model.entity.NtbDoct;
|
import it.integry.ems_model.entity.NtbDoct;
|
||||||
import it.integry.ems_model.types.OperationType;
|
import it.integry.ems_model.types.OperationType;
|
||||||
import it.integry.ems_model.utility.UtilityDB;
|
import it.integry.ems_model.utility.*;
|
||||||
import it.integry.ems_model.utility.UtilityDate;
|
|
||||||
import it.integry.ems_model.utility.UtilityHashMap;
|
|
||||||
import it.integry.ems_model.utility.UtilityString;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
@@ -35,7 +32,8 @@ public class DocumentCheckRules {
|
|||||||
Integer annoAtt = new Integer(DatiAzi.get("anno_attuale").toString());
|
Integer annoAtt = new Integer(DatiAzi.get("anno_attuale").toString());
|
||||||
Integer annoContab = new Integer(DatiAzi.get("anno_contab").toString());
|
Integer annoContab = new Integer(DatiAzi.get("anno_contab").toString());
|
||||||
Date ultDataGio = dateformat.parse(DatiAzi.get("ult_data_gio").toString());
|
Date ultDataGio = dateformat.parse(DatiAzi.get("ult_data_gio").toString());
|
||||||
Integer annoMov = Integer.valueOf(annoFormat.format(dataCmov)).intValue();
|
|
||||||
|
Integer annoMov = AccountingRules.getAnnoComp(conn, dataCmov);
|
||||||
|
|
||||||
Integer numIreg = entity.getDtbTipi().getNumIreg();
|
Integer numIreg = entity.getDtbTipi().getNumIreg();
|
||||||
String codIreg = entity.getDtbTipi().getCodIreg();
|
String codIreg = entity.getDtbTipi().getCodIreg();
|
||||||
@@ -76,31 +74,26 @@ public class DocumentCheckRules {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void checkData(DtbDoct entity, Connection conn) throws Exception {
|
private static void checkData(DtbDoct entity, Connection conn) throws Exception {
|
||||||
Date dataToChk = null;
|
// Date dataToChk = null;
|
||||||
Integer ggUtili = 0, segnoLiquid = 0;
|
// Integer ggUtili = 0, segnoLiquid = 0;
|
||||||
PreparedStatement info;
|
// PreparedStatement info;
|
||||||
ResultSet res;
|
// ResultSet res;
|
||||||
SimpleDateFormat annoFormat = new SimpleDateFormat("yyyy");
|
// SimpleDateFormat annoFormat = new SimpleDateFormat("yyyy");
|
||||||
Date dataNow = new Date();
|
// Date dataNow = new Date();
|
||||||
|
|
||||||
// ACQUISIZION DATI DOCUMENTO
|
// ACQUISIZION DATI DOCUMENTO
|
||||||
String codCcau = entity.getDtbTipi().getCodCcau();
|
String codCcau = entity.getDtbTipi().getCodCcau();
|
||||||
|
|
||||||
String codIreg = entity.getDtbTipi().getCodIreg();
|
String codIreg = entity.getDtbTipi().getCodIreg();
|
||||||
|
|
||||||
// ACQUISIZIONE DATI REGISTRO
|
// ACQUISIZIONE DATI REGISTRO
|
||||||
String sql =
|
String sql =
|
||||||
"SELECT segno_liquid " +
|
"SELECT Cast(segno_liquid as int)" +
|
||||||
" FROM ctb_ireg" +
|
" FROM ctb_ireg" +
|
||||||
" WHERE cod_ireg = " + UtilityDB.valueToString(codIreg);
|
" WHERE cod_ireg = " + UtilityDB.valueToString(codIreg);
|
||||||
info = conn.prepareStatement(sql);
|
|
||||||
res = info.executeQuery();
|
|
||||||
while (res.next()) {
|
|
||||||
segnoLiquid = res.getInt(1);
|
|
||||||
}
|
|
||||||
res.close();
|
|
||||||
info.close();
|
|
||||||
|
|
||||||
|
Integer segnoLiquid = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
|
||||||
|
|
||||||
|
Date dataToChk;
|
||||||
if (segnoLiquid == 1) {
|
if (segnoLiquid == 1) {
|
||||||
dataToChk = entity.getDataDoc();
|
dataToChk = entity.getDataDoc();
|
||||||
} else {
|
} else {
|
||||||
@@ -115,11 +108,16 @@ public class DocumentCheckRules {
|
|||||||
HashMap<String, Object> DatiAzi = Azienda.getDatiAzienda(conn);
|
HashMap<String, Object> DatiAzi = Azienda.getDatiAzienda(conn);
|
||||||
Integer annoAtt = new Integer(DatiAzi.get("anno_attuale").toString());
|
Integer annoAtt = new Integer(DatiAzi.get("anno_attuale").toString());
|
||||||
Integer annoMagaz = new Integer(DatiAzi.get("anno_magaz").toString());
|
Integer annoMagaz = new Integer(DatiAzi.get("anno_magaz").toString());
|
||||||
|
|
||||||
|
Integer ggUtili = 0;
|
||||||
if (DatiAzi.get("gg_utili") != null) {
|
if (DatiAzi.get("gg_utili") != null) {
|
||||||
ggUtili = new Integer(DatiAzi.get("gg_utili").toString());
|
ggUtili = new Integer(DatiAzi.get("gg_utili").toString());
|
||||||
}
|
}
|
||||||
Integer annoComp = Integer.valueOf(annoFormat.format(dataToChk)).intValue();
|
|
||||||
Integer giorni = UtilityDate.DaysAfter(dataToChk, dataNow);
|
|
||||||
|
Integer annoComp = AccountingRules.getAnnoComp(conn, dataToChk);
|
||||||
|
|
||||||
|
Integer giorni = UtilityDate.DaysAfter(dataToChk, UtilityDate.getTodayWithoutTime());
|
||||||
|
|
||||||
// CONTROLLO DATA MOVIMENTO
|
// CONTROLLO DATA MOVIMENTO
|
||||||
if (codIreg != null && codCcau != null) {
|
if (codIreg != null && codCcau != null) {
|
||||||
@@ -130,10 +128,8 @@ public class DocumentCheckRules {
|
|||||||
throw new Exception("Data non ammessa. Anno documento diverso da anno magazzino e anno attuale.");
|
throw new Exception("Data non ammessa. Anno documento diverso da anno magazzino e anno attuale.");
|
||||||
}
|
}
|
||||||
// CONTROLLO GIORNI UTILI PER LA MODIFICA
|
// CONTROLLO GIORNI UTILI PER LA MODIFICA
|
||||||
if (ggUtili != 0 && ggUtili > 0 && codCcau != null) {
|
if (ggUtili != 0 && ggUtili > 0 && codCcau != null && giorni > ggUtili) {
|
||||||
if (giorni > ggUtili) {
|
throw new Exception("Data non ammessa. Giorni utili per la modifica " + ggUtili + ".");
|
||||||
throw new Exception("Data non ammessa. Giorni utili per la modifica " + ggUtili + ".");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -239,12 +235,6 @@ public class DocumentCheckRules {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Boolean checkDataDoc(Connection conn, DtbDoct entity) throws Exception {
|
public static Boolean checkDataDoc(Connection conn, DtbDoct entity) throws Exception {
|
||||||
String sql;
|
|
||||||
Date dataRegNew = null;
|
|
||||||
PreparedStatement info;
|
|
||||||
ResultSet res;
|
|
||||||
SimpleDateFormat annoFormat = new SimpleDateFormat("yyyy");
|
|
||||||
|
|
||||||
// ACQUISIZIONE DATI CHIAVE
|
// ACQUISIZIONE DATI CHIAVE
|
||||||
String codAnag = entity.getCodAnag();
|
String codAnag = entity.getCodAnag();
|
||||||
String codDtip = entity.getCodDtip();
|
String codDtip = entity.getCodDtip();
|
||||||
@@ -255,22 +245,16 @@ public class DocumentCheckRules {
|
|||||||
String gestione = entity.getGestione(); /*LEGGERE DA ENTITY*/
|
String gestione = entity.getGestione(); /*LEGGERE DA ENTITY*/
|
||||||
|
|
||||||
// ACQUSIZIONE DATI DOCUMENTO
|
// ACQUSIZIONE DATI DOCUMENTO
|
||||||
|
Date dataRegNew = null;
|
||||||
if (dataReg == null) {
|
if (dataReg == null) {
|
||||||
sql =
|
String sql = "SELECT data_reg " +
|
||||||
"SELECT data_reg " +
|
" FROM dtb_doct" +
|
||||||
" FROM dtb_doct" +
|
" WHERE cod_anag = " + UtilityDB.valueToString(codAnag) + " AND " +
|
||||||
" WHERE cod_anag = " + UtilityDB.valueToString(codAnag) + " AND " +
|
" cod_dtip = " + UtilityDB.valueToString(codDtip) + " AND " +
|
||||||
" cod_dtip = " + UtilityDB.valueToString(codDtip) + " AND " +
|
" data_doc = " + UtilityDB.valueDateToString(dataDoc, CommonConstants.DATE_FORMAT_YMD) + " AND " +
|
||||||
" data_doc = " + UtilityDB.valueDateToString(dataDoc, CommonConstants.DATE_FORMAT_YMD) + " AND " +
|
" ser_doc = " + UtilityDB.valueToString(serDoc) + " AND " +
|
||||||
" ser_doc = " + UtilityDB.valueToString(serDoc) + " AND " +
|
" num_doc = " + UtilityDB.valueToString(numDoc);
|
||||||
" num_doc = " + UtilityDB.valueToString(numDoc);
|
dataRegNew = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
|
||||||
info = conn.prepareStatement(sql);
|
|
||||||
res = info.executeQuery();
|
|
||||||
while (res.next()) {
|
|
||||||
dataRegNew = res.getDate(1);
|
|
||||||
}
|
|
||||||
res.close();
|
|
||||||
info.close();
|
|
||||||
} else {
|
} else {
|
||||||
dataRegNew = dataReg;
|
dataRegNew = dataReg;
|
||||||
}
|
}
|
||||||
@@ -309,7 +293,7 @@ public class DocumentCheckRules {
|
|||||||
}
|
}
|
||||||
|
|
||||||
HashMap<String, Object> DatiAzi = Azienda.getDatiAzienda(conn);
|
HashMap<String, Object> DatiAzi = Azienda.getDatiAzienda(conn);
|
||||||
Integer annoDoc = Integer.valueOf(annoFormat.format(dataRegNew)).intValue();
|
Integer annoDoc = AccountingRules.getAnnoComp(conn, dataRegNew);
|
||||||
Integer annoCont = new Integer(DatiAzi.get("anno_contab").toString());
|
Integer annoCont = new Integer(DatiAzi.get("anno_contab").toString());
|
||||||
Integer annoAtt = new Integer(DatiAzi.get("anno_attuale").toString());
|
Integer annoAtt = new Integer(DatiAzi.get("anno_attuale").toString());
|
||||||
if (!(annoDoc.equals(annoCont) || annoDoc.equals(annoAtt))) {
|
if (!(annoDoc.equals(annoCont) || annoDoc.equals(annoAtt))) {
|
||||||
|
|||||||
@@ -311,20 +311,9 @@ public class DocumentRules extends QueryRules {
|
|||||||
Integer annoContab = Integer.parseInt(datiAzienda.get("anno_contab").toString());
|
Integer annoContab = Integer.parseInt(datiAzienda.get("anno_contab").toString());
|
||||||
Integer annoMagaz = Integer.parseInt(datiAzienda.get("anno_magaz").toString());
|
Integer annoMagaz = Integer.parseInt(datiAzienda.get("anno_magaz").toString());
|
||||||
|
|
||||||
sql =
|
Short annoCompCosto = AccountingRules.getAnnoComp(conn, dataReg).shortValue();
|
||||||
Query.format(
|
|
||||||
"SELECT anno\n" +
|
|
||||||
"FROM gtb_periodo_fisc\n" +
|
|
||||||
"WHERE %s BETWEEN data_iniz AND data_fine", dataReg);
|
|
||||||
|
|
||||||
Short annoCompCosto = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
|
Short annoCompDoc = AccountingRules.getAnnoComp(conn, dtbDocr.getDataReg()).shortValue();
|
||||||
|
|
||||||
sql =
|
|
||||||
Query.format(
|
|
||||||
"SELECT anno\n" +
|
|
||||||
"FROM gtb_periodo_fisc\n" +
|
|
||||||
"WHERE %s BETWEEN data_iniz AND data_fine", dtbDocr.getDataReg());
|
|
||||||
Short annoCompDoc = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
|
|
||||||
|
|
||||||
if (annoCompCosto < annoCompDoc && annoContab == annoCompDoc - 1 && annoMagaz == annoCompDoc - 1) {
|
if (annoCompCosto < annoCompDoc && annoContab == annoCompDoc - 1 && annoMagaz == annoCompDoc - 1) {
|
||||||
isDocAp = true;
|
isDocAp = true;
|
||||||
|
|||||||
@@ -852,11 +852,15 @@ public class CtbMovt extends EntityBase {
|
|||||||
ps.close();
|
ps.close();
|
||||||
if (ctbScad == null || ctbScad.size() == 0) {
|
if (ctbScad == null || ctbScad.size() == 0) {
|
||||||
query = "SELECT DISTINCT cs.tipo_anag,\n" + " cs.cod_anag,\n" + " cs.anno_part,\n" + " cs.ser_doc,\n" + " cs.num_doc,\n" + " cs.id_riga\n" + "FROM ctb_movt\n" + " INNER JOIN ctb_caus ON ctb_movt.cod_ccau = ctb_caus.cod_ccau\n" + " INNER JOIN ctb_scad cs ON DatePart(Year, ctb_movt.data_doc) = cs.anno_part AND\n" + " ctb_movt.tipo_anag = cs.tipo_anag AND\n" + " ctb_movt.cod_anag = cs.cod_anag AND\n" + " ctb_movt.ser_doc = cs.ser_doc AND\n" + " ctb_movt.num_doc = cs.num_doc\n" + "WHERE ctb_movt.num_cmov = " + getNumCmov() + "\n" + " AND ctb_caus.azione_su_partita = 0";
|
query = "SELECT DISTINCT cs.tipo_anag,\n" + " cs.cod_anag,\n" + " cs.anno_part,\n" + " cs.ser_doc,\n" + " cs.num_doc,\n" + " cs.id_riga\n" + "FROM ctb_movt\n" + " INNER JOIN ctb_caus ON ctb_movt.cod_ccau = ctb_caus.cod_ccau\n" + " INNER JOIN ctb_scad cs ON DatePart(Year, ctb_movt.data_doc) = cs.anno_part AND\n" + " ctb_movt.tipo_anag = cs.tipo_anag AND\n" + " ctb_movt.cod_anag = cs.cod_anag AND\n" + " ctb_movt.ser_doc = cs.ser_doc AND\n" + " ctb_movt.num_doc = cs.num_doc\n" + "WHERE ctb_movt.num_cmov = " + getNumCmov() + "\n" + " AND ctb_caus.azione_su_partita = 0";
|
||||||
ctbScad = new ResultSetMapper().mapQuerySetToList(connection, query, CtbScad.class, OperationType.DELETE);
|
List<CtbScad> del = new ResultSetMapper().mapQuerySetToList(connection, query, CtbScad.class, OperationType.DELETE);
|
||||||
|
if (del != null)
|
||||||
|
for ( CtbScad s: del)
|
||||||
|
s.manageWithParentConnection(connection, s.getOperation(), dataCompleting, entityHolder);
|
||||||
}
|
}
|
||||||
if (ctbPart == null) {
|
if (ctbPart == null) {
|
||||||
query = "SELECT cs.tipo_anag,\n" + " cs.cod_anag,\n" + " cs.anno_part,\n" + " cs.ser_doc,\n" + " cs.num_doc\n" + "FROM ctb_movt\n" + " INNER JOIN ctb_caus ON ctb_movt.cod_ccau = ctb_caus.cod_ccau\n" + " INNER JOIN ctb_part cs ON DatePart(Year, ctb_movt.data_doc) = cs.anno_part AND\n" + " ctb_movt.tipo_anag = cs.tipo_anag AND\n" + " ctb_movt.cod_anag = cs.cod_anag AND\n" + " ctb_movt.ser_doc = cs.ser_doc AND\n" + " ctb_movt.num_doc = cs.num_doc\n" + "WHERE ctb_movt.num_cmov = " + getNumCmov() + "\n" + " AND ctb_caus.azione_su_partita = 0";
|
query = "SELECT cs.tipo_anag,\n" + " cs.cod_anag,\n" + " cs.anno_part,\n" + " cs.ser_doc,\n" + " cs.num_doc\n" + "FROM ctb_movt\n" + " INNER JOIN ctb_caus ON ctb_movt.cod_ccau = ctb_caus.cod_ccau\n" + " INNER JOIN ctb_part cs ON DatePart(Year, ctb_movt.data_doc) = cs.anno_part AND\n" + " ctb_movt.tipo_anag = cs.tipo_anag AND\n" + " ctb_movt.cod_anag = cs.cod_anag AND\n" + " ctb_movt.ser_doc = cs.ser_doc AND\n" + " ctb_movt.num_doc = cs.num_doc\n" + "WHERE ctb_movt.num_cmov = " + getNumCmov() + "\n" + " AND ctb_caus.azione_su_partita = 0";
|
||||||
ctbPart = new ResultSetMapper().mapQueryToObject(connection, query, CtbPart.class, OperationType.DELETE);
|
ctbPart = new ResultSetMapper().mapQueryToObject(connection, query, CtbPart.class, OperationType.DELETE);
|
||||||
|
if (ctbPart != null) ctbPart.manageWithParentConnection(connection, ctbPart.getOperation(), dataCompleting, entityHolder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ when
|
|||||||
eval(completeRulesEnabled)
|
eval(completeRulesEnabled)
|
||||||
$entity : CtbMovt(annoComp == null)
|
$entity : CtbMovt(annoComp == null)
|
||||||
then
|
then
|
||||||
Integer anno = AccountingRules.completeAnnoComp( conn, $entity.getDataCmov());
|
Integer anno = AccountingRules.getAnnoComp( conn, $entity.getDataCmov());
|
||||||
modify ( $entity ) { setAnnoComp(anno) }
|
modify ( $entity ) { setAnnoComp(anno) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -75,17 +75,6 @@ public class AmmortamentiService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private Integer getAnnoFisc(Date dataVal) throws Exception {
|
|
||||||
query = "SELECT anno FROM gtb_periodo_fisc WHERE " + UtilityDB.valueDateToString(dataVal, CommonConstants.DATE_FORMAT_YMD) + " between data_iniz and data_fine";
|
|
||||||
Integer annoFisc = (Integer) QueryRules.getSingleValue(multiDBTransactionManager.getPrimaryConnection(), query);
|
|
||||||
if (annoFisc == null) {
|
|
||||||
throw new Exception("Impossibile individuare l'anno fiscale dalla data " + UtilityDB.valueDateToString(dataVal, CommonConstants.DATE_FORMAT_DMY));
|
|
||||||
}
|
|
||||||
return annoFisc;
|
|
||||||
}
|
|
||||||
|
|
||||||
private BigDecimal getResiduo(Integer anno, String codBene, String tipo) throws Exception {
|
private BigDecimal getResiduo(Integer anno, String codBene, String tipo) throws Exception {
|
||||||
BigDecimal residuo = null;
|
BigDecimal residuo = null;
|
||||||
|
|
||||||
|
|||||||
@@ -446,6 +446,12 @@ public class RossoGarganoSyncService {
|
|||||||
codDtip = "TD16";
|
codDtip = "TD16";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String sql = Query.format("SELECT segno_ireg FROM ctb_caus WHERE cod_ccau = %s ", ctbMovt.getCodCcau());
|
||||||
|
BigDecimal segnoReg = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||||
|
if (UtilityBigDecimal.lowerThan(segnoReg, BigDecimal.ZERO) ) {
|
||||||
|
codDtip = "N" + codDtip;
|
||||||
|
}
|
||||||
|
|
||||||
AutofatturaDTO autofatturaDTO =
|
AutofatturaDTO autofatturaDTO =
|
||||||
new AutofatturaDTO().setCodDtip(codDtip)
|
new AutofatturaDTO().setCodDtip(codDtip)
|
||||||
.setDescrizione(String.format("AUTOFATTURA EMESSA A FRONTE DELLA FATTURA N.%s DEL %s",
|
.setDescrizione(String.format("AUTOFATTURA EMESSA A FRONTE DELLA FATTURA N.%s DEL %s",
|
||||||
|
|||||||
@@ -45,10 +45,8 @@ public class ScadenzeService {
|
|||||||
|
|
||||||
if (ctbScads != null && ctbScads.size() > 0 ) {
|
if (ctbScads != null && ctbScads.size() > 0 ) {
|
||||||
List<String> collect = ctbScads.stream().map(
|
List<String> collect = ctbScads.stream().map(
|
||||||
x -> {
|
x -> String.format("Cod anag: %s - %s, anno_part: %s, numero: %s/%s ",
|
||||||
return String.format("Cod anag: %s - %s, anno_part: %s, numero: %s/%s ",
|
x.getTipoAnag(), x.getCodAnag(), x.getAnnoPart(), x.getSerDoc(), x.getNumDoc())
|
||||||
x.getTipoAnag(), x.getCodAnag(), x.getAnnoPart(), x.getSerDoc(), x.getNumDoc());
|
|
||||||
}
|
|
||||||
).collect(Collectors.toList());
|
).collect(Collectors.toList());
|
||||||
|
|
||||||
String elencoScadenze = String.join(CommonConstants.A_CAPO, collect);
|
String elencoScadenze = String.join(CommonConstants.A_CAPO, collect);
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import it.integry.ems.response.ServiceRestResponse;
|
|||||||
import it.integry.ems.system.dto.SqlObjectDTO;
|
import it.integry.ems.system.dto.SqlObjectDTO;
|
||||||
import it.integry.ems.system.service.SystemMigrationService;
|
import it.integry.ems.system.service.SystemMigrationService;
|
||||||
import it.integry.ems.utility.UtilityDebug;
|
import it.integry.ems.utility.UtilityDebug;
|
||||||
|
import it.integry.ems_model.base.EntityBase;
|
||||||
|
import it.integry.ems_model.entity.StbGestSetup;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
@@ -38,4 +40,19 @@ public class SystemMigrationController {
|
|||||||
return ServiceRestResponse.createPositiveResponse();
|
return ServiceRestResponse.createPositiveResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "createFromGestSetup", method = RequestMethod.POST)
|
||||||
|
public @ResponseBody
|
||||||
|
ServiceRestResponse createFromGestSetup(@RequestBody List<StbGestSetup> entityBaseList) throws Exception {
|
||||||
|
|
||||||
|
if (!UtilityDebug.isDebugExecution())
|
||||||
|
throw new Exception("Puoi eseguire questa procedura solo in ambiente DEBUG!");
|
||||||
|
|
||||||
|
if (UtilityDebug.isIntegryServerDev())
|
||||||
|
throw new Exception("Non puoi eseguire questa azione su SERVERDEV!");
|
||||||
|
|
||||||
|
systemMigrationService.createFromGestSetup(entityBaseList);
|
||||||
|
|
||||||
|
return ServiceRestResponse.createPositiveResponse();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,9 +5,17 @@ import it.integry.ems.migration._base.BaseMigration;
|
|||||||
import it.integry.ems.migration.dto.SqlObjectTypeEnum;
|
import it.integry.ems.migration.dto.SqlObjectTypeEnum;
|
||||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||||
import it.integry.ems.system.dto.SqlObjectDTO;
|
import it.integry.ems.system.dto.SqlObjectDTO;
|
||||||
|
import it.integry.ems.utility.UtilityEntity;
|
||||||
|
import it.integry.ems_model.base.EntityBase;
|
||||||
|
import it.integry.ems_model.config.EmsRestConstants;
|
||||||
|
import it.integry.ems_model.entity.StbGestSetup;
|
||||||
|
import it.integry.ems_model.entity.StbGestSetupQuery;
|
||||||
|
import it.integry.ems_model.service.SetupGest;
|
||||||
|
import it.integry.ems_model.types.OperationType;
|
||||||
import it.integry.ems_model.utility.Query;
|
import it.integry.ems_model.utility.Query;
|
||||||
import it.integry.ems_model.utility.UtilityDB;
|
import it.integry.ems_model.utility.UtilityDB;
|
||||||
import it.integry.ems_model.utility.UtilityLocalDate;
|
import it.integry.ems_model.utility.UtilityLocalDate;
|
||||||
|
import it.integry.ems_model.utility.UtilityString;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -17,8 +25,15 @@ import java.io.FileOutputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStreamWriter;
|
import java.io.OutputStreamWriter;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@Scope(value = "request")
|
@Scope(value = "request")
|
||||||
@@ -73,6 +88,142 @@ public class SystemMigrationService {
|
|||||||
return readObjects;
|
return readObjects;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void createFromGestSetup(List<StbGestSetup> entityBaseList) throws IOException {
|
||||||
|
String migrationClassName = "Migration_" + CommonConstants.TIMESTAMP_FORMATTER.format(UtilityLocalDate.getNowTime());
|
||||||
|
|
||||||
|
StringBuilder classBuilder = new StringBuilder("package it.integry.ems.migration.model;\n" +
|
||||||
|
"\n" +
|
||||||
|
"import it.integry.ems.migration._base.BaseMigration;\n" +
|
||||||
|
"import it.integry.ems.migration._base.MigrationModelInterface;\n" +
|
||||||
|
"\n" +
|
||||||
|
"public class " + migrationClassName + " extends BaseMigration implements MigrationModelInterface {\n" +
|
||||||
|
"\n" +
|
||||||
|
" @Override\n" +
|
||||||
|
" public void up() throws Exception {\n" +
|
||||||
|
" if (isHistoryDB())\n" +
|
||||||
|
" return;\n" +
|
||||||
|
"\n" +
|
||||||
|
"\n");
|
||||||
|
|
||||||
|
|
||||||
|
for (StbGestSetup setup:entityBaseList){
|
||||||
|
|
||||||
|
String operation;
|
||||||
|
if (setup.getOperation() == OperationType.DELETE) {
|
||||||
|
operation = formatSetup("deleteSetup(%s, %s, %s);", setup.getGestName(), setup.getSection(), setup.getKeySection());
|
||||||
|
|
||||||
|
classBuilder.append("\t\t" + operation)
|
||||||
|
.append("\r\n");
|
||||||
|
} else {
|
||||||
|
if (!UtilityString.isNullOrEmpty(setup.getQueryDefault())){
|
||||||
|
operation =
|
||||||
|
formatSetup(
|
||||||
|
"createSetupQuery(%s, %s, %s, %s);",
|
||||||
|
setup.getCodQuery(),setup.getCodQuery(),setup.getQueryDefault(), false);
|
||||||
|
classBuilder.append("\t\t" + operation)
|
||||||
|
.append("\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
operation =
|
||||||
|
formatSetup(
|
||||||
|
"createSetup(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s);",
|
||||||
|
setup.getGestName(),
|
||||||
|
setup.getSection(),
|
||||||
|
setup.getKeySection(),
|
||||||
|
setup.getValue(),
|
||||||
|
setup.getDescription(),
|
||||||
|
setup.getFlagSync().equalsIgnoreCase("S"),
|
||||||
|
setup.getCodQuery(),
|
||||||
|
setup.getFlagUserView().equalsIgnoreCase("S"),
|
||||||
|
setup.getFlagSetupDepo().equalsIgnoreCase("S"),
|
||||||
|
setup.getFlagSetupUserWeb().equalsIgnoreCase("S"),
|
||||||
|
setup.getFlagTipoJson().equalsIgnoreCase("S"),
|
||||||
|
UtilityString.equalsIgnoreCase(setup.getFlagTipoColore(),"S"),
|
||||||
|
setup.getTipoSetup(),
|
||||||
|
setup.getFlagMultiValue()==null?false:setup.getFlagMultiValue(),
|
||||||
|
setup.getQueryDefault() );
|
||||||
|
|
||||||
|
classBuilder.append("\t\t" + operation)
|
||||||
|
.append("\r\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
classBuilder.append(
|
||||||
|
" }\n" +
|
||||||
|
"\n" +
|
||||||
|
" @Override\n" +
|
||||||
|
" public void down() throws Exception {\n" +
|
||||||
|
"\n" +
|
||||||
|
" }\n" +
|
||||||
|
"\n" +
|
||||||
|
"}\n");
|
||||||
|
|
||||||
|
|
||||||
|
String executionPath = new File(BaseMigration.class.getProtectionDomain().getCodeSource().getLocation().getPath()).getAbsolutePath();
|
||||||
|
final String baseProjectPath = executionPath.substring(0, executionPath.indexOf("ems-engine\\target")) + "ems-core\\src\\main\\";
|
||||||
|
final String migrationsJavaPath = baseProjectPath + "java\\it\\integry\\ems\\migration\\model\\";
|
||||||
|
final String migrationsJavaFile = migrationsJavaPath + migrationClassName + ".java";
|
||||||
|
writeContentToFile(migrationsJavaFile, classBuilder.toString(), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String formatSetup(String string, Object... params) {
|
||||||
|
String[] formattedParams = new String[params.length];
|
||||||
|
for(int i = 0; i < params.length; i++) {
|
||||||
|
if (params[i] == null || params[i].equals(EmsRestConstants.NULL)) {
|
||||||
|
formattedParams[i] = "null";
|
||||||
|
} else {
|
||||||
|
String className = params[i].getClass().getName();
|
||||||
|
int pos = className.lastIndexOf(".");
|
||||||
|
if (pos > 0) {
|
||||||
|
String type = className.substring(pos + 1).toUpperCase();
|
||||||
|
formattedParams[i] = params[i].toString();
|
||||||
|
|
||||||
|
if (formattedParams[i].length() == 0) {
|
||||||
|
formattedParams[i] = "null";
|
||||||
|
} else {
|
||||||
|
switch (type) {
|
||||||
|
case "STRING":
|
||||||
|
formattedParams[i] = "\"" + formattedParams[i].replaceAll("\"", "''").replaceAll("’", "''") + "\"";
|
||||||
|
break;
|
||||||
|
case "DATE": {
|
||||||
|
SimpleDateFormat dateFormatFile = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
formattedParams[i] = "\"" + dateFormatFile.format(params[i]) + "\"";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "LOCALDATE": {
|
||||||
|
formattedParams[i] = "\"" + CommonConstants.DATE_YMD_DASHED_FORMATTER.format((LocalDate) params[i]) + "\"";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "LOCALDATETIME": {
|
||||||
|
formattedParams[i] = "\"" + CommonConstants.DATETIME_YMD_DASHED_FORMATTER.format((LocalDateTime) params[i]) + "\"";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "TIMESTAMP":
|
||||||
|
case "INSTANT": {
|
||||||
|
if (type.equalsIgnoreCase("INSTANT")) {
|
||||||
|
params[i] = Date.from((Instant) params[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
SimpleDateFormat dateFormatFile = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
formattedParams[i] = "\"" + dateFormatFile.format(params[i]) + "\"";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "BOOLEAN":
|
||||||
|
formattedParams[i] = ((Boolean) params[i]) ? "true" : "false";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
formattedParams[i] = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return String.format(string, formattedParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void createMigrationFileFromSqlObjects(List<SqlObjectDTO> sqlObjects) throws IOException {
|
public void createMigrationFileFromSqlObjects(List<SqlObjectDTO> sqlObjects) throws IOException {
|
||||||
|
|
||||||
@@ -107,7 +258,7 @@ public class SystemMigrationService {
|
|||||||
.append(typeName)
|
.append(typeName)
|
||||||
.append("(\"").append(sqlObject.getName()).append("\"").append(", ")
|
.append("(\"").append(sqlObject.getName()).append("\"").append(", ")
|
||||||
.append("\"").append(definition).append("\");")
|
.append("\"").append(definition).append("\");")
|
||||||
.append("\r\n\r\n");
|
.append("\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
classBuilder.append(
|
classBuilder.append(
|
||||||
|
|||||||
Reference in New Issue
Block a user