Gestione plafond reso
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
package it.integry.ems.migration.model;import it.integry.ems.migration._base.BaseMigration;
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20240326120018 extends BaseMigration implements MigrationModelInterface {
|
||||
@@ -7,6 +9,9 @@ public class Migration_20240326120018 extends BaseMigration implements Migration
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
executeStatement("ALTER TABLE vtb_agen_budget ADD flag_tipologia varchar(1) null default 'B'",
|
||||
"UPDATE vtb_agen_budget SET flag_tipologia = 'B'",
|
||||
"ALTER TABLE vtb_agen_budget ALTER COLUMN flag_tipologia varchar(1) not null");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
package it.integry.ems.migration.model;import it.integry.ems.migration._base.BaseMigration;
|
||||
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_20240326130416 extends BaseMigration implements MigrationModelInterface {
|
||||
@@ -7,6 +10,11 @@ public class Migration_20240326130416 extends BaseMigration implements Migration
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
if (!isCustomerDb(
|
||||
IntegryCustomerDB.Salpar_VgAlimenti))
|
||||
return;
|
||||
|
||||
executeStatement("UPDATE vtb_agen_budget SET flag_tipologia = 'S' where flag_tipologia = 'B'");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
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_20240326131400 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (!isCustomerDb(
|
||||
IntegryCustomerDB.Salpar_VgAlimenti))
|
||||
return;
|
||||
|
||||
createOrUpdateProcedure("x_puddy3_prev_popolate_plafond_reso", "CREATE PROCEDURE [dbo].[x_puddy3_prev_popolate_plafond_reso] AS\n" +
|
||||
"BEGIN\n" +
|
||||
" create table #tempTable\n" +
|
||||
" ( cod_vage varchar(5) not null, \n" +
|
||||
" anno integer not null, \n" +
|
||||
" mese integer not null,\n" +
|
||||
" importo_plafond numeric(20,5) not null default 0, \n" +
|
||||
" importo_plafond_residuo numeric(20, 5) not null default 0);\n" +
|
||||
"\n" +
|
||||
" insert into #tempTable\n" +
|
||||
" select vtb_agen_budget.cod_vage,\n" +
|
||||
" vtb_agen_budget.anno, \n" +
|
||||
" vtb_agen_budget.mese,\n" +
|
||||
" vtb_agen_budget.importo as importo_plafond,\n" +
|
||||
" vtb_agen_budget.importo - ISNULL(plafondMensile.importo_plafond_utilizzato, 0) as importo_plafond_utilizzato\n" +
|
||||
" from vtb_agen_budget left outer join (select dtb_doct.cod_vage, \n" +
|
||||
" DATEPART(YEAR, dtb_doct.data_doc) as anno, \n" +
|
||||
" DATEPART(month, dtb_doct.data_doc) as mese, \n" +
|
||||
" sum(round(qta_doc * val_unt, 2)) as importo_plafond_utilizzato\n" +
|
||||
" from dtb_doct inner join dtb_docr on dtb_doct.cod_dtip = dtb_docr.cod_dtip and\n" +
|
||||
" dtb_doct.cod_anag = dtb_docr.cod_anag and\n" +
|
||||
" dtb_doct.data_doc = dtb_docr.data_doc and\n" +
|
||||
" dtb_doct.ser_doc = dtb_docr.ser_doc and\n" +
|
||||
" dtb_doct.num_doc = dtb_docr.num_doc \n" +
|
||||
" inner join dtb_tipi on dtb_doct.cod_dtip = dtb_tipi.cod_dtip \n" +
|
||||
" where tipo_emissione = 'DIRETTA' and\n" +
|
||||
" dtb_doct.gestione = 'V' and\n" +
|
||||
" dtb_doct.data_doc >= CONVERT(datetime, CONVERT(varchar, DATEPART(year, DATEADD(MONTH, -9, GETDATE()))) + '-' + CONVERT(varchar, DATEPART(month, DATEADD(MONTH, -9, GETDATE()))) + '-01') and\n" +
|
||||
" dtb_tipi.segno_qta_scar = -1 and\n" +
|
||||
" dtb_doct.cod_vage is not null and\n" +
|
||||
" dtb_doct.cod_anag not in (select cod_anag from x_puddy3_prev_plafond_reso_clienti_esclusi)\n" +
|
||||
" group by dtb_doct.cod_vage, \n" +
|
||||
" DATEPART(YEAR, dtb_doct.data_doc),\n" +
|
||||
" DATEPART(month, dtb_doct.data_doc))plafondMensile on plafondMensile.cod_vage = vtb_agen_budget.cod_vage and\n" +
|
||||
" plafondMensile.anno = vtb_agen_budget.anno and\n" +
|
||||
" plafondMensile.mese = vtb_agen_budget.mese\n" +
|
||||
" where vtb_agen_budget.flag_tipologia = 'R'\n" +
|
||||
"\n" +
|
||||
" delete from x_puddy3_prev_plafond_reso \n" +
|
||||
" from x_puddy3_prev_plafond_reso inner join (select distinct cod_vage, anno, mese from #tempTable)mesi on x_puddy3_prev_plafond_reso.cod_vage = mesi.cod_vage and\n" +
|
||||
" x_puddy3_prev_plafond_reso.anno = mesi.anno and\n" +
|
||||
" x_puddy3_prev_plafond_reso.mese = mesi.mese\n" +
|
||||
"\n" +
|
||||
" insert into x_puddy3_prev_plafond_reso \n" +
|
||||
" select * from #tempTable;\n" +
|
||||
"END");
|
||||
|
||||
}
|
||||
|
||||
@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.IntegryCustomerDB;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20240326131414 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (!isCustomerDb(
|
||||
IntegryCustomerDB.Salpar_VgAlimenti))
|
||||
return;
|
||||
|
||||
createOrUpdateProcedure("x_puddy3_prev_popolate_plafond_sconto_fresc", "CREATE PROCEDURE [dbo].[x_puddy3_prev_popolate_plafond_sconto_fresc] AS\n" +
|
||||
"BEGIN\n" +
|
||||
" create table #tempTable\n" +
|
||||
" ( cod_vage varchar(5) not null, \n" +
|
||||
" anno integer not null, \n" +
|
||||
" mese integer not null,\n" +
|
||||
" importo_plafond numeric(20,5) not null default 0, \n" +
|
||||
" importo_plafond_residuo numeric(20, 5) not null default 0);\n" +
|
||||
"\n" +
|
||||
" insert into #tempTable\n" +
|
||||
" select vtb_agen_budget.cod_vage,\n" +
|
||||
" vtb_agen_budget.anno, \n" +
|
||||
" vtb_agen_budget.mese,\n" +
|
||||
" vtb_agen_budget.importo as importo_plafond,\n" +
|
||||
" vtb_agen_budget.importo - ISNULL(plafondMensile.importo_plafond_utilizzato, 0) as importo_plafond_utilizzato\n" +
|
||||
" from vtb_agen_budget left outer join (select dtb_doct.cod_vage, \n" +
|
||||
" DATEPART(YEAR, dtb_doct.data_doc) as anno, \n" +
|
||||
" DATEPART(month, dtb_doct.data_doc) as mese, \n" +
|
||||
" sum(round(qta_doc * val_unt, 2)) as importo_plafond_utilizzato\n" +
|
||||
" from dtb_doct inner join dtb_docr on dtb_doct.cod_dtip = dtb_docr.cod_dtip and\n" +
|
||||
" dtb_doct.cod_anag = dtb_docr.cod_anag and\n" +
|
||||
" dtb_doct.data_doc = dtb_docr.data_doc and\n" +
|
||||
" dtb_doct.ser_doc = dtb_docr.ser_doc and\n" +
|
||||
" dtb_doct.num_doc = dtb_docr.num_doc \n" +
|
||||
" inner join dtb_tipi on dtb_doct.cod_dtip = dtb_tipi.cod_dtip \n" +
|
||||
" where tipo_emissione = 'DIRETTA' and\n" +
|
||||
" dtb_doct.gestione = 'V' and\n" +
|
||||
" dtb_doct.data_doc >= CONVERT(datetime, CONVERT(varchar, DATEPART(year, DATEADD(MONTH, -9, GETDATE()))) + '-' + CONVERT(varchar, DATEPART(month, DATEADD(MONTH, -9, GETDATE()))) + '-01') and\n" +
|
||||
" dtb_docr.sconto8 = 100 and\n" +
|
||||
" dtb_doct.cod_vage is not null and\n" +
|
||||
" dtb_doct.cod_anag not in (select cod_anag from x_puddy3_prev_plafond_sconto_fresc_clienti_esclusi)\n" +
|
||||
" group by dtb_doct.cod_vage, \n" +
|
||||
" DATEPART(YEAR, dtb_doct.data_doc),\n" +
|
||||
" DATEPART(month, dtb_doct.data_doc))plafondMensile on plafondMensile.cod_vage = vtb_agen_budget.cod_vage and\n" +
|
||||
" plafondMensile.anno = vtb_agen_budget.anno and\n" +
|
||||
" plafondMensile.mese = vtb_agen_budget.mese\n" +
|
||||
" where vtb_agen_budget.flag_tipologia = 'S'\n" +
|
||||
"\n" +
|
||||
" delete from x_puddy3_prev_plafond_sconto_fresc \n" +
|
||||
" from x_puddy3_prev_plafond_sconto_fresc inner join (select distinct cod_vage, anno, mese from #tempTable)mesi on x_puddy3_prev_plafond_sconto_fresc.cod_vage = mesi.cod_vage and\n" +
|
||||
" x_puddy3_prev_plafond_sconto_fresc.anno = mesi.anno and\n" +
|
||||
" x_puddy3_prev_plafond_sconto_fresc.mese = mesi.mese\n" +
|
||||
"\n" +
|
||||
" insert into x_puddy3_prev_plafond_sconto_fresc \n" +
|
||||
" select * from #tempTable;\n" +
|
||||
"END");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -43,6 +43,9 @@ public class VtbAgenBudget extends EntityBase {
|
||||
@SqlField(value = "mese", nullable = true)
|
||||
private Integer mese;
|
||||
|
||||
@SqlField(value = "flag_tipologia", maxLength = 1, nullable = false, defaultObjectValue = "B")
|
||||
private String flagTipologia;
|
||||
|
||||
public VtbAgenBudget() {
|
||||
super();
|
||||
}
|
||||
@@ -102,4 +105,12 @@ public class VtbAgenBudget extends EntityBase {
|
||||
public void setCodMtip(String codMtip) {
|
||||
this.codMtip = codMtip;
|
||||
}
|
||||
|
||||
public String getFlagTipologia() {
|
||||
return flagTipologia;
|
||||
}
|
||||
|
||||
public void setFlagTipologia(String flagTipologia) {
|
||||
this.flagTipologia = flagTipologia;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user