Divisa setup TIPO_MOVIMENTO_FISCALE in TIPO_MOVIMENTO_FISCALE_CAR e TIPO_MOVIMENTO_FISCALE_SCAR
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good

This commit is contained in:
2025-12-05 18:14:35 +01:00
parent 6d8e0e747f
commit 2008ef0e8f
3 changed files with 91 additions and 28 deletions

View File

@@ -177,7 +177,7 @@ public abstract class BaseMigration implements MigrationModelInterface {
} }
protected void cloneTable(String sourceTable, String newTable,boolean fillNewTable, boolean dropOldTable, boolean renameNewTable) throws Exception { protected void cloneTable(String sourceTable, String newTable, boolean fillNewTable, boolean dropOldTable, boolean renameNewTable) throws Exception {
UtilityDB.cloneTable(connection, sourceTable, newTable, fillNewTable, dropOldTable, renameNewTable); UtilityDB.cloneTable(connection, sourceTable, newTable, fillNewTable, dropOldTable, renameNewTable);
} }
@@ -423,6 +423,25 @@ public abstract class BaseMigration implements MigrationModelInterface {
} }
} }
protected String getSetupValue(String gestName, String section, String keySection) throws SQLException {
String sql = Query.format("SELECT value FROM " + StbGestSetup.ENTITY +
" WHERE gest_name = %s AND" +
" section = %s AND" +
" key_section = %s", gestName, section, keySection);
return UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
}
//Create a getStbGestSetup method to return the entire StbGestSetup object
protected StbGestSetup getStbGestSetup(String gestName, String section, String keySection) throws SQLException, DataConverterNotFoundException, InstantiationException, IllegalAccessException {
String sql = Query.format("SELECT * FROM stb_gest_setup " +
" WHERE gest_name = %s AND" +
" section = %s AND" +
" key_section = %s", gestName, section, keySection);
return UtilityDB.executeSimpleQueryOnlyFirstRowDTO(connection, sql, StbGestSetup.class);
}
protected void deleteSetup(String gestName, String section, String keySection) throws Exception { protected void deleteSetup(String gestName, String section, String keySection) throws Exception {
StbGestSetup stbGestSetup = new StbGestSetup() StbGestSetup stbGestSetup = new StbGestSetup()
.setGestName(gestName) .setGestName(gestName)

View File

@@ -0,0 +1,38 @@
package it.integry.ems.migration.model;
import it.integry.ems.migration._base.BaseMigration;
import it.integry.ems.migration._base.MigrationModelInterface;
import it.integry.ems_model.entity.StbGestSetup;
public class Migration_20251205173303 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
StbGestSetup setupMovimentoFiscale = getStbGestSetup("PICKING", "RETTIFICA_GIACENZE", "TIPO_MOVIMENTO_FISCALE");
deleteSetup("PICKING", "RETTIFICA_GIACENZE", "TIPO_MOVIMENTO_FISCALE");
createSetup(setupMovimentoFiscale.getGestName(),
setupMovimentoFiscale.getSection(),
setupMovimentoFiscale.getKeySection() + "_CAR",
setupMovimentoFiscale.getValue(),
setupMovimentoFiscale.getDescription(),
setupMovimentoFiscale.getQueryDefault());
createSetup(setupMovimentoFiscale.getGestName(),
setupMovimentoFiscale.getSection(),
setupMovimentoFiscale.getKeySection() + "_SCAR",
setupMovimentoFiscale.getValue(),
setupMovimentoFiscale.getDescription(),
setupMovimentoFiscale.getQueryDefault());
}
@Override
public void down() throws Exception {
}
}

View File

@@ -1256,10 +1256,16 @@ public class WMSGenericService {
DtbDoct dtbDoctInv = null; DtbDoct dtbDoctInv = null;
if (shouldCreateMovimentoFiscale && isDocumentAttached) { if (shouldCreateMovimentoFiscale && isDocumentAttached) {
String codDtipToUse = setupGest.getSetup(multiDBTransactionManager.getPrimaryConnection(), "PICKING", "RETTIFICA_GIACENZE", "TIPO_MOVIMENTO_FISCALE"); String codDtipToUse = null;
if (isPositiveUpdate)
codDtipToUse = setupGest.getSetup(multiDBTransactionManager.getPrimaryConnection(), "PICKING", "RETTIFICA_GIACENZE", "TIPO_MOVIMENTO_FISCALE_CAR");
else
codDtipToUse = setupGest.getSetup(multiDBTransactionManager.getPrimaryConnection(), "PICKING", "RETTIFICA_GIACENZE", "TIPO_MOVIMENTO_FISCALE_SCAR");
if (UtilityString.isNullOrEmpty(codDtipToUse)) if (UtilityString.isNullOrEmpty(codDtipToUse))
throw new Exception("Per poter generare il movimento fiscale è necessario configurare anche la setup TIPO_MOVIMENTO_FISCALE"); throw new Exception("Per poter generare il movimento fiscale è necessario configurare la setup PICKING > RETTIFICA_GIACENZE > TIPO_MOVIMENTO_FISCALE" +
(isPositiveUpdate ? "_CAR" : "_SCAR"));
String sqlCheckDocExists = Query.format("SELECT TOP 1 cod_anag, cod_dtip, ser_doc, data_doc, num_doc " + String sqlCheckDocExists = Query.format("SELECT TOP 1 cod_anag, cod_dtip, ser_doc, data_doc, num_doc " +
@@ -1587,13 +1593,13 @@ public class WMSGenericService {
mtbColtToInsert = WMSUtility.createUDSLavorazioneMovement(multiDBTransactionManager, mtbColtToInsert = WMSUtility.createUDSLavorazioneMovement(multiDBTransactionManager,
new CreateUDSRequestDTO() new CreateUDSRequestDTO()
.setCausaleCollo(CreateUDSRequestDTO.Causale.SCARICO) .setCausaleCollo(CreateUDSRequestDTO.Causale.SCARICO)
.setCodMdep(codMdep) .setCodMdep(codMdep)
.setCodJfas(codJfas == null ? scaricoMateriaPrimaDTO.getCodJfas() : codJfas) .setCodJfas(codJfas == null ? scaricoMateriaPrimaDTO.getCodJfas() : codJfas)
.setPosizione(scaricoMateriaPrimaDTO.getPosizione()) .setPosizione(scaricoMateriaPrimaDTO.getPosizione())
.setCodAnag(codAnag) .setCodAnag(codAnag)
.setOrders(Collections.singletonList(new CreateUDSRequestOrderDTO() .setOrders(Collections.singletonList(new CreateUDSRequestOrderDTO()
.setDataOrd(scaricoMateriaPrimaDTO.getDataOrd()) .setDataOrd(scaricoMateriaPrimaDTO.getDataOrd())
.setNumOrd(scaricoMateriaPrimaDTO.getNumOrd()) .setNumOrd(scaricoMateriaPrimaDTO.getNumOrd())
.setGestione(scaricoMateriaPrimaDTO.getGestioneOrd()))), .setGestione(scaricoMateriaPrimaDTO.getGestioneOrd()))),
userSession.getUsername()); userSession.getUsername());
} }
@@ -1632,13 +1638,13 @@ public class WMSGenericService {
final InsertUDSRowResponseDTO insertedUds = WMSUtility.insertUDSLavorazioneRowMovement(multiDBTransactionManager.getPrimaryConnection(), final InsertUDSRowResponseDTO insertedUds = WMSUtility.insertUDSLavorazioneRowMovement(multiDBTransactionManager.getPrimaryConnection(),
new InsertUDSRowRequestDTO() new InsertUDSRowRequestDTO()
.setTargetMtbColt(mtbColtToInsert) .setTargetMtbColt(mtbColtToInsert)
.setCodMart(giacInPosizioneItem.getCodMart()) .setCodMart(giacInPosizioneItem.getCodMart())
.setCodJcom(giacInPosizioneItem.getCodJcom()) .setCodJcom(giacInPosizioneItem.getCodJcom())
.setNumOrd(scaricoMateriaPrimaDTO.getNumOrd()) .setNumOrd(scaricoMateriaPrimaDTO.getNumOrd())
.setDataOrd(scaricoMateriaPrimaDTO.getDataOrd()) .setDataOrd(scaricoMateriaPrimaDTO.getDataOrd())
.setRigaOrd(giacInPosizioneItem.getRigaOrd()) .setRigaOrd(giacInPosizioneItem.getRigaOrd())
.setQtaTot(qtaToTake) .setQtaTot(qtaToTake)
.setPartitaMag(giacInPosizioneItem.getPartitaMag()) .setPartitaMag(giacInPosizioneItem.getPartitaMag())
.setSourceMtbColr(WMSUtility.convertMvwItemToMtbColr(giacInPosizioneItem)) .setSourceMtbColr(WMSUtility.convertMvwItemToMtbColr(giacInPosizioneItem))
.setDatetimeRow(UtilityLocalDate.getNowTime()), .setDatetimeRow(UtilityLocalDate.getNowTime()),
userSession.getUsername()); userSession.getUsername());
@@ -1732,9 +1738,9 @@ public class WMSGenericService {
MtbColt mtbColt = mtbColtsToInsert MtbColt mtbColt = mtbColtsToInsert
.stream() .stream()
.filter(x -> scaricoDaOrdine.getDataOrd().equals(x.getDataOrd()) && .filter(x -> scaricoDaOrdine.getDataOrd().equals(x.getDataOrd()) &&
scaricoDaOrdine.getNumOrd().equals(x.getNumOrd()) && scaricoDaOrdine.getNumOrd().equals(x.getNumOrd()) &&
scaricoDaOrdine.getGestioneOrd().equals(x.getGestione()) && scaricoDaOrdine.getGestioneOrd().equals(x.getGestione()) &&
giacenza.getPosizione().equals(x.getPosizione()) && giacenza.getPosizione().equals(x.getPosizione()) &&
(codJfasScarico != null && codJfasScarico.equalsIgnoreCase(x.getCodJfas()))) (codJfasScarico != null && codJfasScarico.equalsIgnoreCase(x.getCodJfas())))
.findFirst() .findFirst()
.orElse(null); .orElse(null);
@@ -1761,14 +1767,14 @@ public class WMSGenericService {
} else { } else {
mtbColt = WMSUtility.createUDSLavorazioneMovement(multiDBTransactionManager, mtbColt = WMSUtility.createUDSLavorazioneMovement(multiDBTransactionManager,
new CreateUDSRequestDTO() new CreateUDSRequestDTO()
.setCodMdep(codMdep) .setCodMdep(codMdep)
.setCodJfas(codJfasScarico) .setCodJfas(codJfasScarico)
.setPosizione(giacenza.getPosizione()) .setPosizione(giacenza.getPosizione())
.setCodAnag(codAnag) .setCodAnag(codAnag)
.setCausaleCollo(CreateUDSRequestDTO.Causale.SCARICO) .setCausaleCollo(CreateUDSRequestDTO.Causale.SCARICO)
.setOrders(Collections.singletonList(new CreateUDSRequestOrderDTO() .setOrders(Collections.singletonList(new CreateUDSRequestOrderDTO()
.setDataOrd(scaricoDaOrdine.getDataOrd()) .setDataOrd(scaricoDaOrdine.getDataOrd())
.setNumOrd(scaricoDaOrdine.getNumOrd()) .setNumOrd(scaricoDaOrdine.getNumOrd())
.setGestione(scaricoDaOrdine.getGestioneOrd()))), .setGestione(scaricoDaOrdine.getGestioneOrd()))),
userSession.getUsername()); userSession.getUsername());
} }
@@ -1788,13 +1794,13 @@ public class WMSGenericService {
WMSUtility.insertUDSLavorazioneRowMovement(multiDBTransactionManager.getPrimaryConnection(), WMSUtility.insertUDSLavorazioneRowMovement(multiDBTransactionManager.getPrimaryConnection(),
new InsertUDSRowRequestDTO() new InsertUDSRowRequestDTO()
.setTargetMtbColt(mtbColt) .setTargetMtbColt(mtbColt)
.setCodMart(giacenza.getCodMart()) .setCodMart(giacenza.getCodMart())
.setCodJcom(giacenza.getCodJcom()) .setCodJcom(giacenza.getCodJcom())
.setNumOrd(scaricoDaOrdine.getNumOrd()) .setNumOrd(scaricoDaOrdine.getNumOrd())
.setDataOrd(scaricoDaOrdine.getDataOrd()) .setDataOrd(scaricoDaOrdine.getDataOrd())
.setRigaOrd(giacenza.getRigaOrd()) .setRigaOrd(giacenza.getRigaOrd())
.setQtaTot(qtaToTake) .setQtaTot(qtaToTake)
.setPartitaMag(giacenza.getPartitaMag()) .setPartitaMag(giacenza.getPartitaMag())
.setSourceMtbColr(WMSUtility.convertMvwItemToMtbColr(giacenza)) .setSourceMtbColr(WMSUtility.convertMvwItemToMtbColr(giacenza))
.setDatetimeRow(UtilityLocalDate.getNowTime()), .setDatetimeRow(UtilityLocalDate.getNowTime()),
userSession.getUsername()); userSession.getUsername());