Modifica Invio fatture elettroniche x GRAMM

This commit is contained in:
2025-04-10 17:42:30 +02:00
parent 9256771b28
commit a1ab837794
4 changed files with 168 additions and 4 deletions

View File

@@ -0,0 +1,98 @@
package it.integry.ems.migration.model;
import it.integry.ems.migration._base.BaseMigration;
import it.integry.ems.migration._base.IntegryCustomerDB;
import it.integry.ems.migration._base.MigrationModelInterface;
public class Migration_20250409170559 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
if (!isCustomerDb(IntegryCustomerDB.Gramm_Gramm))
return;
createOrUpdateFunction("getDocuPrint", "CREATE FUNCTION [dbo].[getDocuPrint]\n" +
"( \n" +
" @codAnag varchar(5), @codDtip varchar(5), @dataDoc datetime, @serDoc varchar(2), @numDoc int\n" +
") RETURNS TABLE AS\n" +
"\n" +
"RETURN \n" +
"select docu.cod_anag,\n" +
" cod_dtip,\n" +
" data_doc,\n" +
" ser_doc,\n" +
" num_doc,\n" +
" tipo_cessione, \n" +
" id_riga,\n" +
" docu.cod_mart,\n" +
" descrizione,\n" +
" ISNULL(dbo.f_emptyStr2Null((select value from stb_gest_setup where gest_name = 'FATTURA_ELETTRONICA_CUSTOM' and section = 'COD_ANAG_' + docu.cod_anag and key_section = 'CODICEARTICOLO_EAN_TIPO')), tipo_codice_ean) as tipo_codice_ean, \n" +
" valore_codice_ean,\n" +
" ISNULL(dbo.f_emptyStr2Null((select value from stb_gest_setup where gest_name = 'FATTURA_ELETTRONICA_CUSTOM' and section = 'COD_ANAG_' + docu.cod_anag and key_section = 'CODICEARTICOLO_FORN_TIPO')), tipo_codice_forn) as tipo_codice_forn, \n" +
" valore_codice_forn,\n" +
" ISNULL(dbo.f_emptyStr2Null((select value from stb_gest_setup where gest_name = 'FATTURA_ELETTRONICA_CUSTOM' and section = 'COD_ANAG_' + docu.cod_anag and key_section = 'CODICEARTICOLO_CLIE_TIPO')), tipo_codice_clie) as tipo_codice_clie,\n" +
" CASE docu.cod_anag WHEN 'C1275' THEN mtb_aart_anag.cod_mart_anag ELSE valore_codice_clie END as valore_codice_clie,\n" +
" ISNULL(dbo.f_emptyStr2Null((select value from stb_gest_setup where gest_name = 'FATTURA_ELETTRONICA_CUSTOM' and section = 'COD_ANAG_' + docu.cod_anag and key_section = 'ALTRIDATI_CT_ART_TIPO')), tipodato_ct_art) as tipodato_ct_art,\n" +
" CASE WHEN docu.cod_anag in ('C1217', 'C1606', 'C1944', 'C0966', 'C1799', 'C1587') THEN num_cnf ELSE rifNumero_ct_art END as rifNumero_ct_art,\n" +
" rifTesto_ct_art,\n" +
" ISNULL(dbo.f_emptyStr2Null((select value from stb_gest_setup where gest_name = 'FATTURA_ELETTRONICA_CUSTOM' and section = 'COD_ANAG_' + docu.cod_anag and key_section = 'ALTRIDATI_PZ_ART_TIPO')), tipodato_pz_art) as tipodato_pz_art,\n" +
" CASE WHEN docu.cod_anag in ('C1217', 'C1606', 'C1944', 'C0966', 'C1799', 'C1587') THEN qta_cnf ELSE rifNumero_pz_art END as rifNumero_pz_art, \n" +
" rifTesto_pz_art,\n" +
" case when dbo.getGestSetup('FATTURA_ELETTRONICA_CUSTOM', 'COD_ANAG_' + docu.cod_anag, 'UNITA_MISURA_EDI') = 'S' THEN dbo.GetDocuPrint_getUMEDI(unt_doc) ELSE unt_doc END as unt_doc , \n" +
" qta_doc,\n" +
" val_unt,\n" +
" sconto5,\n" +
" sconto6,\n" +
" sconto7,\n" +
" sconto8,\n" +
" importo_riga,\n" +
" docu.cod_aliq,\n" +
" perc_aliq, \n" +
" natura, \n" +
" data_iniz_comp,\n" +
" data_fine_comp,\n" +
" cod_kit,\n" +
" descr_kit,\n" +
" tipodato_lotto,\n" +
" rifTesto_lotto,\n" +
" ISNULL(case when docu.cod_anag = 'C0966' then 'DP' + '|' else '' end + dbo.f_emptyStr2Null((select value from stb_gest_setup where gest_name = 'FATTURA_ELETTRONICA_CUSTOM' and section = 'COD_ANAG_' + docu.cod_anag and key_section = 'ALTRIDATI_DEST_TIPO')), tipodato_dest) as tipodato_dest,\n" +
" CASE docu.cod_anag \n" +
" WHEN 'C0326' THEN null \n" +
" WHEN 'C0731' THEN null \n" +
" WHEN 'C0328' THEN null \n" +
" WHEN 'C0432' THEN null\n" +
" WHEN 'C1830' THEN null ELSE rifNumero_dest END as rifNumero_dest,\n" +
" LEFT(CASE docu.cod_anag \n" +
" WHEN 'C2499' then SPACE(1) /*Necessario per nom visualizzare l'indirizzo come richiesto dal cliente*/\n" +
" WHEN 'C1765' THEN vtb_dest.destinatario \n" +
" WHEN 'C1275' THEN vtb_dest.cod_ean\n" +
" WHEN 'C0432' THEN vtb_dest.cod_affiliazione\n" +
" WHEN 'C1830' THEN vtb_dest.cod_ean\n" +
" WHEN 'C0328' THEN vtb_dest.cod_affiliazione\n" +
" WHEN 'C0731' THEN vtb_dest.cod_ean\n" +
" WHEN 'C0326' THEN vtb_dest.cod_affiliazione ELSE\n" +
" CASE WHEN docu.cod_anag in ('C1217', 'C1606', 'C1944', 'C1799', 'C1587') THEN vtb_dest.cod_ean +';'+vtb_dest.destinatario ELSE case when docu.cod_anag in ('C0966') then vtb_dest.cod_ean +'|'+vtb_dest.destinatario else rifTesto_dest END END END, 60) as rifTesto_dest, \n" +
" data_ddt, \n" +
" CASE docu.cod_anag WHEN 'C0731' THEN \n" +
" CASE WHEN isNull(num_doc_ddt, '') = '' THEN null ELSE ser_doc_ddt + ' ' + Cast(num_doc_ddt as varchar) END \n" +
" ELSE num_ddt END as num_ddt, \n" +
" rif_data_ord, \n" +
" rif_num_ord, \n" +
" rifTesto_numDocCli, \n" +
" tipoDato_numDocCli\n" +
"from dbo.getDocuPrint_generica(@codAnag, @CodDtip, @dataDoc, @serDoc, @numDoc) docu left outer join vtb_dest on docu.cod_anag = vtb_dest.cod_anag and\n" +
" docu.cod_vdes = vtb_dest.cod_vdes\n" +
" left outer join mtb_aart_anag on docu.cod_anag = mtb_aart_anag.cod_anag and \n" +
" docu.cod_mart = mtb_aart_anag.cod_mart\n" +
"where docu.cod_anag <> 'C0326' OR (docu.cod_anag = 'C0326' AND docu.qta_doc <> 0 AND docu.val_unt <> 0 AND isnull(natura,'') <>'N2.2')");
}
@Override
public void down() throws Exception {
}
}

View File

@@ -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_20250410130654 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
createSetup("W_VLISTDATA_RC", "SETUP", "SUGGESTCODE_PROMO", null,
"Se non specificato nulla viene passato alla suggestcode il partial_code = cod_vlis, altrimenti viene passato il partial_code = codice_promo specificato dall'utente", false, null, false, false,
false, false, false, null, false, null);
}
@Override
public void down() throws Exception {
}
}

View File

@@ -0,0 +1,41 @@
package it.integry.ems.migration.model;
import it.integry.ems.migration._base.BaseMigration;
import it.integry.ems.migration._base.IntegryCustomerDB;
import it.integry.ems.migration._base.MigrationModelInterface;
public class Migration_20250410130713 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
if (!isCustomerDb(IntegryCustomerDB.Gramm_Gramm))
return;
updateSetupValue("W_VLISTDATA_RC", "SETUP", "SUGGESTCODE_PROMO", "COD_PROMO",
"Se non specificato nulla viene passato alla suggestcode il partial_code = cod_vlis, altrimenti viene passato il partial_code = codice_promo specificato dall'utente", false, null, false, false, false,
false, false, null, false, null);
executeStatement("DELETE\n" +
"FROM stb_gest_setup_depo\n" +
"WHERE gest_name = 'W_VLISTDATA_RC'\n" +
" AND section = 'SETUP'\n" +
" AND key_section = 'SUGGESTCODE_PROMO'"
);
executeStatement("DELETE\n" +
"FROM wtb_gest_setup_user\n" +
"WHERE gest_name = 'W_VLISTDATA_RC'\n" +
" AND section = 'SETUP'\n" +
" AND key_section = 'SUGGESTCODE_PROMO'"
);
}
@Override
public void down() throws Exception {
}
}

View File

@@ -1057,10 +1057,10 @@ public class DigitalInvoiceBodyFactory {
if (setup.getSetupBoolean("FATTURA_ELETTRONICA_CUSTOM", "ALTRI_DATI_GESTIONALI_DEST", "ATTIVO")) {
//DESTINATARIO
/*Gestito il carattere | per creare più istanze del tag AltriDatiGestionali per i dati del destinatario*/
if (!UtilityString.isNullOrEmpty(dettaglioLinea.getRifTestoDest())) {
/* if (!UtilityString.isNullOrEmpty(dettaglioLinea.getRifTestoDest())) {*/
List<String> listTipoDato = Arrays.asList(StringUtils.split(UtilityString.streNull(dettaglioLinea.getTipoDatoDest()), "|"));
List<String> listRifTesto = Arrays.asList(StringUtils.split(UtilityString.streNull(dettaglioLinea.getRifTestoDest()), "|"));
if (listTipoDato.size() == listRifTesto.size()) {
if (listTipoDato.size() == listRifTesto.size() && listTipoDato != null && listRifTesto != null) {
for (int j = 0; j < listTipoDato.size(); j++) {
AltriDatiGestionaliType altriDatiDest = new AltriDatiGestionaliType();
altriDatiDest.setTipoDato(listTipoDato.get(j));
@@ -1074,9 +1074,11 @@ public class DigitalInvoiceBodyFactory {
dettaglio.getAltriDatiGestionali().add(altriDatiDest);
}
} else {
throw new Exception("Configurazione personalizzata non corretta del tag <AltriDatiGertionali> per la visulizzazione del destinatario.");
if (!UtilityString.isNullOrEmpty(dettaglioLinea.getRifTestoDest())){
throw new Exception("Configurazione personalizzata non corretta del tag <AltriDatiGertionali> per la visulizzazione del destinatario.");
}
}
}
/* }*/
}
return dettaglio;