Merge remote-tracking branch 'origin/develop' into develop

This commit is contained in:
2024-06-11 15:33:53 +02:00
4 changed files with 209 additions and 1 deletions

View File

@@ -0,0 +1,27 @@
package it.integry.ems.migration.model;
import it.integry.ems.migration._base.BaseMigration;
import it.integry.ems.migration._base.IntegryCustomer;
import it.integry.ems.migration._base.MigrationModelInterface;
public class Migration_20240611102244 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
createSetupQuery(null, null, "SELECT '0|Data Ordine' UNION ALL SELECT '1|Data Consegna'", false);
createSetup("W_VSITUAZ_CONS_DISP", "SETUP", "PERIODO_RIF", "0", "Indica se il sottotitolo ha come periodo di riferimento la data ordine o la data consegna", false, null, false, false, false, false, false, null, false, "SELECT '0|Data Ordine' UNION ALL SELECT '1|Data Consegna'");
if (isCustomer(IntegryCustomer.Salpar))
updateSetupValue("W_VSITUAZ_CONS_DISP", "SETUP", "PERIODO_RIF", "1");
}
@Override
public void down() throws Exception {
}
}

View File

@@ -0,0 +1,64 @@
package it.integry.ems.migration.model;
import it.integry.ems.migration._base.BaseMigration;
import it.integry.ems.migration._base.MigrationModelInterface;
public class Migration_20240611110703 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
createOrUpdateFunction("getListinoVenditaRange", "CREATE FUNCTION [dbo].[getListinoVenditaRange](@datavalidita DATETIME, @codvlis VARCHAR(5), @codmart VARCHAR(15), @pedane INT)\n" +
" RETURNS TABLE AS\n" +
" RETURN\n" +
" WITH trasp AS (SELECT mtb_lisv_data_spese.cod_vlis,\n" +
" mtb_lisv_data_spese.versione,\n" +
" mtb_lisv_data_spese.cod_spes,\n" +
" mtb_lisv_data_spese.perc_ricarico,\n" +
" mtb_lisv_data_spese.val_ricarico,\n" +
" mtb_lisv_data_spese.perc_sconto,\n" +
" mtb_lisv_data_spese.da,\n" +
" mtb_lisv_data_spese.a\n" +
" FROM (SELECT cod_vlis,\n" +
" MAX(CASE\n" +
" WHEN vtb_list_data.versione IS NULL THEN NULL\n" +
" ELSE CONVERT(VARCHAR(10), vtb_list_data.data_iniz, 111) + ' ' +\n" +
" REPLICATE('0', 5 - LEN(vtb_list_data.versione)) +\n" +
" CONVERT(VARCHAR(5), vtb_list_data.versione) END) AS max_lisv\n" +
" FROM vtb_list_data\n" +
" WHERE vtb_list_data.data_iniz <= ISNULL(@datavalidita, CAST(GETDATE() AS DATE))\n" +
" GROUP BY cod_vlis) t\n" +
" INNER JOIN vtb_list_data ON t.cod_vlis = vtb_list_data.cod_vlis AND\n" +
" CONVERT(INT, RIGHT(t.max_lisv, 5)) = vtb_list_data.versione\n" +
" INNER JOIN mtb_lisv_data_spese\n" +
" ON vtb_list_data.cod_vlis = mtb_lisv_data_spese.cod_vlis AND\n" +
" vtb_list_data.versione = mtb_lisv_data_spese.versione)\n" +
"\n" +
" SELECT list.*,\n" +
" trasp.cod_spes,\n" +
" trasp.perc_ricarico,\n" +
" trasp.val_ricarico,\n" +
" trasp.perc_sconto,\n" +
" trasp.da,\n" +
" trasp.a,\n" +
" (list.prz_vend +\n" +
" IIF(list.flag_add_trasp = 1,\n" +
" ((ISNULL(val_ricarico, 0)) * list.add_val_spese) /\n" +
" IIF(ISNULL(list.colli_pedana, 1) = 0, 1, list.colli_pedana), 0)) +\n" +
" ((ISNULL(perc_ricarico, 0) * list.add_ric_spese * list.prz_vend) / 100) *\n" +
" (1 - (ISNULL(perc_sconto, 0) * list.add_sco_spese) / 100) prz_vend_trasp\n" +
" FROM getlistinovendita(@datavalidita, @codvlis, @codmart) list\n" +
" LEFT OUTER JOIN trasp ON list.cod_vlis = trasp.cod_vlis AND\n" +
" (@pedane IS NULL OR @pedane BETWEEN da AND a OR\n" +
" (@pedane IS NOT NULL AND da = 0 AND a = 0))");
}
@Override
public void down() throws Exception {
}
}

View File

@@ -0,0 +1,117 @@
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_20240611120635 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
if (!isCustomerDb(IntegryCustomerDB.RossoGargano_RossoGargano))
return;
createOrUpdateFunction("RG_AnalisiVendite_KPI", "CREATE FUNCTION [dbo].[RG_AnalisiVendite_KPI](@idBdg BIGINT, @formato VARCHAR(40) = NULL, @famiglia VARCHAR(40) = NULL)\n" +
" RETURNS TABLE AS\n" +
" RETURN(WITH detailTab AS\n" +
" (SELECT YEAR(vtb_bdgt.budget_da) AS AnnoFiscale,\n" +
" ISNULL(art.cod_mart_Stat, art.cod_mart) AS CodArticolo,\n" +
" ISNULL(art_Stat.descrizione, art.descrizione) AS Articolo,\n" +
" mtb_sgrp.descrizione AS famiglia,\n" +
" mtb_tipi.descrizione AS formato,\n" +
" ms.descrizione AS sottoformato,\n" +
" ROUND(SUM(car.CAR_QTA * art.qta_cnf), 0) AS QtaProdotta,\n" +
" 0 AS QtaVenduta,\n" +
" 0 AS QtaBudget,\n" +
" 0 AS Giacenza\n" +
"\n" +
" FROM RossoGarganoExchange.dbo.WCARICHI_TAB Car\n" +
" INNER JOIN (SELECT DISTINCT SCAR_ANNO_C, SCAR_TIPO_C, SCAR_NUM_C\n" +
" FROM RossoGarganoExchange.dbo.WSCARICHI_TAB) scar\n" +
" ON car.CAR_TIPO = scar.SCAR_TIPO_C AND\n" +
" car.CAR_ANNO = scar.SCAR_ANNO_C AND\n" +
" car.CAR_NUMERO = scar.SCAR_NUM_C\n" +
" INNER JOIN rossoGargano.dbo.mtb_aart art ON Car.CAR_ART = art.cod_mart\n" +
" LEFT OUTER JOIN RossoGargano.dbo.mtb_aart art_stat\n" +
" ON art.cod_mart_stat = art_stat.cod_mart\n" +
" INNER JOIN mtb_grup ON art.cod_mgrp = mtb_grup.cod_mgrp\n" +
" INNER JOIN mtb_sgrp\n" +
" ON art.cod_mgrp = mtb_sgrp.cod_mgrp AND art.cod_msgr = mtb_sgrp.cod_msgr\n" +
" LEFT OUTER JOIN mtb_tipi ON art.cod_mtip = mtb_tipi.cod_mtip\n" +
" LEFT OUTER JOIN mtb_stip ms\n" +
" ON art_stat.cod_mtip = ms.cod_mtip AND art_stat.cod_mstp = ms.cod_mstp\n" +
" INNER JOIN vtb_bdgt ON id_bdg = @idBdg\n" +
" INNER JOIN RossoGarganoExchange.dbo.mtb_partitamag_prefisso\n" +
" ON mtb_partitamag_prefisso.Anno =\n" +
" YEAR(rossogargano.dbo.vtb_bdgt.budget_da)\n" +
" WHERE CAR_DTINS >= CONVERT(VARCHAR(4), mtb_partitamag_prefisso.anno) + '/01/01'\n" +
" AND mtb_grup.tipo_mgrp = 'SL'\n" +
" AND car_lotto LIKE mtb_partitamag_prefisso.prefisso + '%'\n" +
" GROUP BY YEAR(vtb_bdgt.budget_da), art.cod_mart, art.descrizione, mtb_sgrp.descrizione,\n" +
" mtb_tipi.descrizione, ms.descrizione, art.cod_mart_stat, art_stat.descrizione\n" +
"\n" +
" UNION ALL\n" +
" SELECT anno_c AS AnnoFiscale,\n" +
" cod_mart AS codArticolo,\n" +
" descrizione AS Articolo,\n" +
" famiglia,\n" +
" formato,\n" +
" sottoformato,\n" +
" 0 AS qta_prodotta,\n" +
" ROUND(SUM(qta_vend_anno_c), 0) AS qta_venduta,\n" +
" 0 AS budget,\n" +
" 0 AS giacenza\n" +
" FROM dbo.[RG_AnalisiVenditeAnno](@idBdg, 0)\n" +
" GROUP BY anno_c, cod_mart, descrizione, formato, famiglia, sottoformato\n" +
"\n" +
" UNION ALL\n" +
" SELECT YEAR(vtb_bdgt.budget_da) AS anno_fisc,\n" +
" art.cod_mart,\n" +
" art.descrizione,\n" +
" mtb_sgrp.descrizione AS famiglia,\n" +
" mtb_tipi.descrizione AS formato,\n" +
" ms.descrizione AS sottoformato,\n" +
" 0 AS qta_prodotta,\n" +
" 0 AS qta_venduta,\n" +
" ROUND(SUM(vtb_bdgr.qta_budget), 0) AS qtaBudget,\n" +
" 0 AS giacenza\n" +
" FROM vtb_bdgt\n" +
" INNER JOIN vtb_bdgr ON vtb_bdgt.id_bdg = vtb_bdgr.id_bdg\n" +
" INNER JOIN mtb_aart art ON vtb_bdgr.cod_mart = art.cod_mart\n" +
" INNER JOIN mtb_sgrp\n" +
" ON art.cod_mgrp = mtb_sgrp.cod_mgrp AND art.cod_msgr = mtb_sgrp.cod_msgr\n" +
" INNER JOIN mtb_tipi ON art.cod_mtip = mtb_tipi.cod_mtip\n" +
" LEFT OUTER JOIN mtb_stip ms\n" +
" ON art.cod_mtip = ms.cod_mtip AND art.cod_mstp = ms.cod_mstp\n" +
" AND vtb_bdgt.id_bdg = @idBdg\n" +
" WHERE vtb_bdgt.id_bdg = @idBdg\n" +
" GROUP BY YEAR(vtb_bdgt.budget_da),\n" +
" art.cod_mart,\n" +
" art.descrizione,\n" +
" mtb_sgrp.descrizione,\n" +
" mtb_tipi.descrizione,\n" +
" ms.descrizione)\n" +
" SELECT AnnoFiscale,\n" +
" CodArticolo,\n" +
" Articolo,\n" +
" famiglia,\n" +
" formato,\n" +
" sottoformato,\n" +
" SUM(qtaProdotta) AS qtaProdotta,\n" +
" SUM(qtaVenduta) AS qtaVenduta,\n" +
" SUM(qtaBudget) AS qtaBudget\n" +
" FROM detailTab\n" +
" WHERE (@formato IS NULL OR formato = @formato)\n" +
" AND (@famiglia IS NULL OR famiglia = @famiglia)\n" +
" GROUP BY AnnoFiscale, CodArticolo, Articolo, famiglia, formato, sottoformato)");
}
@Override
public void down() throws Exception {
}
}

View File

@@ -343,7 +343,7 @@ public class GiacenzaService {
" AND mtb_colt.data_collo >= %s\n" +
" AND mtb_colt.data_distribuzione is null \n" +
" AND mtb_colt.cod_mdep = %s\n" +
" AND exists (select * from carelli_giacenza_prog c where c.cod_mdep = mtb_colt.cod_mdep and c.cod_mart = mtb_colr.cod_mart and (c.data_reg < mtb_colt.data_collo or IsNull(tipo_car, 'G') = 'G' ))\n " +
" AND exists (select * from carelli_giacenza_prog c where c.cod_mdep = mtb_colt.cod_mdep and c.cod_mart = art.cod_mart_mov and (c.data_reg < mtb_colt.data_collo or IsNull(tipo_car, 'G') = 'G' ))\n " +
"GROUP BY art.cod_mart_mov, mtb_colt.data_ins",
codDtipRett, dataIniz, codMdep);