correzione su aggancio html su importaizone fatture elettroniche per rosso gargano
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
This commit is contained in:
@@ -0,0 +1,23 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
|
||||||
|
public class Migration_20241022184011 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
executeStatement("alter table stb_files_attached add file_ext as ( IIF( CHARINDEX('.', REVERSE(file_name)) > 0, \n" +
|
||||||
|
" SUBSTRING(file_name, LEN(file_name) - CHARINDEX('.', REVERSE(file_name)) + 2, LEN(file_name)), \n" +
|
||||||
|
" '') ) PERSISTED ");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
|
||||||
|
public class Migration_20241023090257 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if ( !existsColumn("dtb_fatture_passive", "cod_dtip") ) {
|
||||||
|
dropColumn("dtb_fatture_passive", "cod_anag");
|
||||||
|
dropColumn("dtb_fatture_passive", "identificativo_sdi");
|
||||||
|
executeStatement("alter table dtb_fatture_passive add cod_dtip varchar(5)",
|
||||||
|
"alter table dtb_fatture_passive add cod_anag varchar(5)",
|
||||||
|
"alter table dtb_fatture_passive add identificativo_sdi varchar(15)"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ( !existsColumn("dtb_fatture_passive_scad", "cod_paga_fe") ) {
|
||||||
|
dropTable("dtb_fatture_passive_scad");
|
||||||
|
executeStatement(
|
||||||
|
"CREATE TABLE [dbo].[dtb_fatture_passive_scad](\n" +
|
||||||
|
"\t[id_attach] [varchar](40) NOT NULL,\n" +
|
||||||
|
"\t[data_scad] [datetime] NOT NULL,\n" +
|
||||||
|
"\t[importo] [numeric](20, 5) NOT NULL,\n" +
|
||||||
|
"\t[cod_paga_fe] [varchar](4) NULL,\n" +
|
||||||
|
"\t[id_riga] [bigint] IDENTITY(1,1) NOT NULL,\n" +
|
||||||
|
" CONSTRAINT [pk_dtb_fatture_passive_scad] PRIMARY KEY CLUSTERED \n" +
|
||||||
|
"(\n" +
|
||||||
|
"\t[id_riga] ASC\n" +
|
||||||
|
") ON [PRIMARY]\n" +
|
||||||
|
") ON [PRIMARY]"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
createOrUpdateView("svw_fattura_elettronica_files", "CREATE View [dbo].[svw_fattura_elettronica_files] as \n" +
|
||||||
|
"WITH setup AS (SELECT CONVERT(DATETIME,\n" +
|
||||||
|
" dbo.getgestsetup('dati_azienda', 'fatturazione_elettronica', 'DATA_MIN_VIEW_FATTURE'),\n" +
|
||||||
|
" 103) data_min)\n" +
|
||||||
|
"SELECT description,\n" +
|
||||||
|
" stb_files_attached.id_attach,\n" +
|
||||||
|
" datetime_attach,\n" +
|
||||||
|
" dtb_fatture_passive.part_iva,\n" +
|
||||||
|
" dtb_fatture_passive.data_doc,\n" +
|
||||||
|
" dtb_fatture_passive.num_doc,\n" +
|
||||||
|
" dtb_fatture_passive.tot_doc,\n" +
|
||||||
|
" dtb_fatture_passive.iban,\n" +
|
||||||
|
" dtb_fatture_passive.cod_dtip,\n" +
|
||||||
|
" (SELECT TOP 1 cod_paga_fe\n" +
|
||||||
|
" FROM dtb_fatture_passive_scad\n" +
|
||||||
|
" WHERE dtb_fatture_passive_scad.id_attach = dtb_fatture_passive.id_attach) AS cod_paga_fe\n" +
|
||||||
|
"FROM stb_files_attached\n" +
|
||||||
|
" INNER JOIN dtb_fatture_passive ON stb_files_attached.parent_id_attach = dtb_fatture_passive.id_attach,\n" +
|
||||||
|
" setup\n" +
|
||||||
|
"WHERE file_ext IN ('P7M', 'XML')\n" +
|
||||||
|
" AND type_attach = 'FP'\n" +
|
||||||
|
" AND stb_files_attached.id_attach = parent_id_attach\n" +
|
||||||
|
" AND (setup.data_min IS NULL OR datetime_attach >= setup.data_min)\n");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
|
||||||
|
public class Migration_20241023132242 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
createOrUpdateView("jvw_timbrature",
|
||||||
|
"create view jvw_timbrature as \n" +
|
||||||
|
"select cod_jflav, data_lav, ingresso, uscita\n" +
|
||||||
|
"from (\n" +
|
||||||
|
"select jtb_rlavr.cod_jflav,\n" +
|
||||||
|
"jtb_rlavr.data_lav,\n" +
|
||||||
|
"jtb_rlavr.da_ora as ingresso,\n" +
|
||||||
|
"lead(jtb_rlavr.a_ora) over (partition by jtb_rlavr.cod_jflav, jtb_rlavr.data_lav order by IsNull(jtb_rlavr.da_ora,jtb_rlavr.a_ora)) uscita\n" +
|
||||||
|
"from jtb_rlavt \n" +
|
||||||
|
"inner join jtb_rlavr on jtb_rlavt.cod_jflav = jtb_rlavr.cod_jflav and jtb_rlavt.data_lav = jtb_rlavr.data_lav\n" +
|
||||||
|
"where \n" +
|
||||||
|
"((jtb_rlavr.da_ora is not null and jtb_rlavr.a_ora is null ) or (jtb_rlavr.da_ora is null and jtb_rlavr.a_ora is not null ))\n" +
|
||||||
|
" ) t\n" +
|
||||||
|
"where ingresso is not null");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -206,7 +206,7 @@ public class PassiveInvoiceService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
StbFilesAttached stbFilesAttached = saveAttachment(fileName, fileContentSigned, fileDesc, message, additionalAttachmentInfo);
|
StbFilesAttached stbFilesAttached = saveAttachment(fileName, fileContentSigned, fileDesc, message, additionalAttachmentInfo, null);
|
||||||
|
|
||||||
FpxToPdfDTO.FpxToPdfFile file = new FpxToPdfDTO.FpxToPdfFile();
|
FpxToPdfDTO.FpxToPdfFile file = new FpxToPdfDTO.FpxToPdfFile();
|
||||||
file.setFileContentBytes(fileContentSigned);
|
file.setFileContentBytes(fileContentSigned);
|
||||||
@@ -219,7 +219,8 @@ public class PassiveInvoiceService {
|
|||||||
|
|
||||||
for (int i = 0; i < pdfs.size(); i++) {
|
for (int i = 0; i < pdfs.size(); i++) {
|
||||||
FpxToPdfDTO.FpxToPdfFile pdf = pdfs.get(i);
|
FpxToPdfDTO.FpxToPdfFile pdf = pdfs.get(i);
|
||||||
StbFilesAttached pdfStbFilesAttached = saveAttachment(pdf.getFileName(), pdf.getFileContentBytes(), prefixDesc + " " + pdf.getDescription(), message, additionalAttachmentInfo);
|
StbFilesAttached pdfStbFilesAttached = saveAttachment(pdf.getFileName(), pdf.getFileContentBytes(), prefixDesc + " " + pdf.getDescription(), message, additionalAttachmentInfo,
|
||||||
|
stbFilesAttached.getParentIdAttach());
|
||||||
digitalInvoiceManager.getPassiveInvoices().get(fileName).put(pdfStbFilesAttached.getIdAttach(), pdf);
|
digitalInvoiceManager.getPassiveInvoices().get(fileName).put(pdfStbFilesAttached.getIdAttach(), pdf);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -356,7 +357,9 @@ public class PassiveInvoiceService {
|
|||||||
mailService.sendMail(null, "notifica-errore", emailDest, null, null, errorMailSubject, errorMailText, false, attachments, false);
|
mailService.sendMail(null, "notifica-errore", emailDest, null, null, errorMailSubject, errorMailText, false, attachments, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private StbFilesAttached saveAttachment(String fileName, byte[] fileContent, String description, Message originalMessage, HashMap<String, Object> additionalInfo) throws Exception {
|
private StbFilesAttached saveAttachment(String fileName,
|
||||||
|
byte[] fileContent, String description, Message originalMessage, HashMap<String, Object> additionalInfo,
|
||||||
|
String parentId) throws Exception {
|
||||||
Date receivedDate = null;
|
Date receivedDate = null;
|
||||||
|
|
||||||
if (originalMessage != null && originalMessage.getReceivedDate() != null) {
|
if (originalMessage != null && originalMessage.getReceivedDate() != null) {
|
||||||
@@ -373,46 +376,46 @@ public class PassiveInvoiceService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Recupero allegato parent
|
// Recupero allegato parent
|
||||||
String parentId = null;
|
String codDtip = UtilityHashMap.getValueIfExists(additionalInfo, COD_DTIP_KEY);
|
||||||
String regexName = ".{0,}([A-Z]{2}[a-z,A-Z,0-9]{2,28}[_][a-z,A-Z,0-9]{1,5}).{0,}";
|
Date dataDoc = UtilityHashMap.getValueIfExists(additionalInfo, DATA_DOC_KEY);
|
||||||
Pattern pattern = Pattern.compile(regexName);
|
String numDoc = UtilityHashMap.getValueIfExists(additionalInfo, NUM_DOC_KEY);
|
||||||
Matcher matcher = pattern.matcher(description);
|
|
||||||
String codDtip = UtilityHashMap.<String>getValueIfExists(additionalInfo, COD_DTIP_KEY);
|
if ( parentId == null ) {
|
||||||
Date dataDoc = UtilityHashMap.<Date>getValueIfExists(additionalInfo, DATA_DOC_KEY);
|
String regexName = ".{0,}([A-Z]{2}[a-z,A-Z,0-9]{2,28}[_][a-z,A-Z,0-9]{1,5}).{0,}";
|
||||||
String numDoc = UtilityHashMap.<String>getValueIfExists(additionalInfo, NUM_DOC_KEY);
|
Pattern pattern = Pattern.compile(regexName);
|
||||||
if (matcher.matches()) {
|
Matcher matcher = pattern.matcher(description);
|
||||||
String invoiceName = matcher.group(1);
|
if (matcher.matches()) {
|
||||||
String sqlParentId =
|
String invoiceName = matcher.group(1);
|
||||||
"SELECT max(stb_files_attached.parent_id_attach) as parent_id_attach " +
|
String sqlParentId =
|
||||||
" FROM stb_files_attached INNER JOIN dtb_fatture_passive ON stb_files_attached.parent_id_attach = dtb_fatture_passive.id_attach " +
|
"SELECT max(stb_files_attached.parent_id_attach) as parent_id_attach " +
|
||||||
" WHERE stb_files_attached.file_name LIKE '%" + invoiceName + "%' AND " +
|
" FROM stb_files_attached INNER JOIN dtb_fatture_passive ON stb_files_attached.parent_id_attach = dtb_fatture_passive.id_attach " +
|
||||||
"dtb_fatture_passive.num_doc = " + UtilityDB.valueToString(numDoc) + " AND " +
|
" WHERE stb_files_attached.file_name LIKE '%" + invoiceName + "%' AND " +
|
||||||
"dtb_fatture_passive.data_doc = " + UtilityDB.valueDateToString(dataDoc, CommonConstants.DATE_FORMAT_YMD);
|
"dtb_fatture_passive.num_doc = " + UtilityDB.valueToString(numDoc) + " AND " +
|
||||||
PreparedStatement psParentId = multiDBTransactionManager.prepareStatement(sqlParentId);
|
"dtb_fatture_passive.data_doc = " + UtilityDB.valueDateToString(dataDoc, CommonConstants.DATE_FORMAT_YMD);
|
||||||
ResultSet rsParentId = psParentId.executeQuery();
|
|
||||||
if (rsParentId.next()) {
|
parentId = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sqlParentId);
|
||||||
parentId = rsParentId.getString("parent_id_attach");
|
|
||||||
}
|
}
|
||||||
rsParentId.close();
|
|
||||||
psParentId.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
List<EntityBase> entityList = new ArrayList<>();
|
List<EntityBase> entityList = new ArrayList<>();
|
||||||
String idAttach = getNextIdAttach();
|
|
||||||
StbFilesAttached stbFilesAttached = new StbFilesAttached();
|
|
||||||
stbFilesAttached.setIdAttach(idAttach);
|
|
||||||
stbFilesAttached.setOperation(OperationType.INSERT);
|
|
||||||
fileName = fileName.replaceAll("'", "''");
|
fileName = fileName.replaceAll("'", "''");
|
||||||
stbFilesAttached.setFileName(fileName);
|
String idAttach = getNextIdAttach();
|
||||||
stbFilesAttached.setDatetimeAttach(receivedDate);
|
|
||||||
stbFilesAttached.setDescription(description);
|
|
||||||
stbFilesAttached.setUserName(requestDataDTO.getUsername());
|
|
||||||
stbFilesAttached.setFileSize(new BigDecimal(fileContent.length));
|
|
||||||
stbFilesAttached.setFlagLock("S");
|
|
||||||
stbFilesAttached.setTypeAttach("FP");
|
|
||||||
String parentActivityId = UtilityString.isNullOrEmpty(parentId) ? idAttach : parentId;
|
String parentActivityId = UtilityString.isNullOrEmpty(parentId) ? idAttach : parentId;
|
||||||
stbFilesAttached.setParentIdAttach(parentActivityId);
|
|
||||||
stbFilesAttached.setContent(fileContent);
|
StbFilesAttached stbFilesAttached =
|
||||||
|
new StbFilesAttached()
|
||||||
|
.setIdAttach(idAttach)
|
||||||
|
.setFileName(fileName)
|
||||||
|
.setDatetimeAttach(receivedDate)
|
||||||
|
.setDescription(description)
|
||||||
|
.setUserName(requestDataDTO.getUsername())
|
||||||
|
.setFileSize(new BigDecimal(fileContent.length))
|
||||||
|
.setFlagLock("S")
|
||||||
|
.setTypeAttach("FP")
|
||||||
|
.setParentIdAttach(parentActivityId)
|
||||||
|
.setContent(fileContent);
|
||||||
|
|
||||||
|
stbFilesAttached.setOperation(OperationType.INSERT);
|
||||||
entityList.add(stbFilesAttached);
|
entityList.add(stbFilesAttached);
|
||||||
|
|
||||||
if (UtilityString.isNullOrEmpty(parentId)) {
|
if (UtilityString.isNullOrEmpty(parentId)) {
|
||||||
@@ -431,17 +434,18 @@ public class PassiveInvoiceService {
|
|||||||
codAnag_FP = rifAutofattura.getCodAnag();
|
codAnag_FP = rifAutofattura.getCodAnag();
|
||||||
}
|
}
|
||||||
|
|
||||||
DtbFatturePassive fatturePassive = new DtbFatturePassive();
|
DtbFatturePassive fatturePassive = new DtbFatturePassive()
|
||||||
|
.setIdAttach(parentActivityId)
|
||||||
|
.setPartIva(UtilityHashMap.<String>getValueIfExists(additionalInfo, PART_IVA_KEY))
|
||||||
|
.setDataDoc(dataDoc_FP)
|
||||||
|
.setNumDoc(numDoc_FP)
|
||||||
|
.setTotDoc(UtilityHashMap.<BigDecimal>getValueIfExists(additionalInfo, TOT_DOC_KEY))
|
||||||
|
.setIban(UtilityHashMap.<String>getValueIfExists(additionalInfo, IBAN_KEY))
|
||||||
|
.setCodDtip(codDtip_FP)
|
||||||
|
.setCodAnag(codAnag_FP)
|
||||||
|
.setIdentificativoSdi(UtilityHashMap.getValueIfExists(additionalInfo, RECEIVED_IDENTIFIER_SDI));
|
||||||
|
|
||||||
fatturePassive.setOperation(OperationType.INSERT_OR_UPDATE);
|
fatturePassive.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||||
fatturePassive.setIdAttach(parentActivityId);
|
|
||||||
fatturePassive.setPartIva(UtilityHashMap.<String>getValueIfExists(additionalInfo, PART_IVA_KEY));
|
|
||||||
fatturePassive.setDataDoc(dataDoc_FP);
|
|
||||||
fatturePassive.setNumDoc(numDoc_FP);
|
|
||||||
fatturePassive.setTotDoc(UtilityHashMap.<BigDecimal>getValueIfExists(additionalInfo, TOT_DOC_KEY));
|
|
||||||
fatturePassive.setIban(UtilityHashMap.<String>getValueIfExists(additionalInfo, IBAN_KEY));
|
|
||||||
fatturePassive.setCodDtip(codDtip_FP);
|
|
||||||
fatturePassive.setCodAnag(codAnag_FP);
|
|
||||||
fatturePassive.setIdentificativoSdi(UtilityHashMap.getValueIfExists(additionalInfo, RECEIVED_IDENTIFIER_SDI));
|
|
||||||
|
|
||||||
List<DtbFatturePassiveScad> scadenze = UtilityHashMap.<List<DtbFatturePassiveScad>>getValueIfExists(additionalInfo, SCADENZE_KEY);
|
List<DtbFatturePassiveScad> scadenze = UtilityHashMap.<List<DtbFatturePassiveScad>>getValueIfExists(additionalInfo, SCADENZE_KEY);
|
||||||
if (scadenze != null && scadenze.size() > 0) {
|
if (scadenze != null && scadenze.size() > 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user