Merge remote-tracking branch 'origin/develop' into develop
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,64 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20250725111448 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
|
||||
createOrUpdateFunction("f_getCodAliq", "CREATE FUNCTION [dbo].[f_getCodAliq](@gestione varchar(1),\n" +
|
||||
" @codMart varchar(15), \n" +
|
||||
" @codAnag varchar(5), \n" +
|
||||
" @codVdes varchar(5), \n" +
|
||||
" @codDtip varchar(5), \n" +
|
||||
" @codPromo varchar(10),\n" +
|
||||
" @sconto5 numeric(5,2),\n" +
|
||||
" @sconto6 numeric(5,2),\n" +
|
||||
" @sconto7 numeric(5,2),\n" +
|
||||
" @sconto8 numeric(5,2))\n" +
|
||||
"RETURNS varchar(5) \n" +
|
||||
"AS\n" +
|
||||
"BEGIN\n" +
|
||||
" -- Declare the return variable here\n" +
|
||||
" DECLARE @codAliq varchar(5)\n" +
|
||||
" DECLARE @percAliq numeric(20,5)\n" +
|
||||
" DECLARE @codAliqEsenz varchar(5)\n" +
|
||||
" select @codAliq = CASE WHEN (select flag_prz_iva FROM dtb_tipi where cod_dtip = @codDtip) = 'S' THEN mtb_aart.cod_aliq \n" +
|
||||
" WHEN (select tipo_iva FROM gtb_aliq WHERE gtb_aliq.cod_aliq = mtb_aart.cod_aliq ) = 'NON ESPOSTA' THEN mtb_aart.cod_aliq \n" +
|
||||
" WHEN ( @sconto5 = 100 OR @sconto6 = 100 OR @sconto7 = 100 OR @sconto8 = 100 ) AND @gestione = 'V' and @codPromo is not null THEN (select case when cod_aliq is null then case when azienda.flag_set_iva_omaggi = 'S' and azienda.cod_iva_omaggi is not null then cod_iva_omaggi else mtb_aart.cod_aliq end else cod_aliq end from vtb_promo where cod_promo = @codPromo) \n" +
|
||||
" WHEN ( @sconto5 = 100 OR @sconto6 = 100 OR @sconto7 = 100 OR @sconto8 = 100 ) and @gestione = 'V' and @codPromo is null and azienda.flag_set_iva_omaggi = 's' and azienda.cod_iva_omaggi is not null THEN azienda.cod_iva_omaggi \n" +
|
||||
" WHEN ( @sconto5 = 100 OR @sconto6 = 100 OR @sconto7 = 100 OR @sconto8 = 100 ) and @gestione = 'V' and @codPromo is null and azienda.flag_set_iva_omaggi = 'N' THEN null\n" +
|
||||
" WHEN @codVdes is not null AND vtb_dest.cod_aliq_in is not null and vtb_dest.cod_aliq_out is not null and (vtb_dest.cod_aliq_in = mtb_aart.cod_aliq OR vtb_dest.cod_aliq_in = anag.cod_aliq) THEN vtb_dest.cod_aliq_out \n" +
|
||||
" WHEN @codVdes is not null AND vtb_dest.cod_aliq_in is not null and vtb_dest.cod_aliq_out is not null and (vtb_dest.cod_aliq_in = mtb_aart.cod_aliq OR vtb_dest.cod_aliq_in = anag.cod_aliq) THEN vtb_dest.cod_aliq_out \n" +
|
||||
" WHEN @codVdes is not null AND vtb_dest.cod_aliq_in is null and vtb_dest.cod_aliq_out is not null THEN vtb_dest.cod_aliq_out \n" +
|
||||
" --WHEN @codVdes is not null AND vtb_dest.cod_aliq_in is null and vtb_dest.cod_aliq_out is null and vtb_dest.cod_aliq is not null then vtb_dest.cod_aliq\n" +
|
||||
" WHEN @codVdes is not null AND vtb_dest.cod_aliq_in is null and vtb_dest.cod_aliq_out is null and vtb_dest.cod_aliq is not null then CASE WHEN gtb_aliq.perc_aliq <> 0 THEN vtb_dest.cod_aliq ELSE mtb_aart.cod_aliq END /*l'eventuale esenzione deve essere impostata solo l'iva non ha già un'esenzione*/\n" +
|
||||
" --WHEN @codVdes is not null AND vtb_dest.cod_aliq_in is null and vtb_dest.cod_aliq_out is null and vtb_dest.cod_aliq is null AND anag.cod_aliq is not null then anag.cod_aliq \n" +
|
||||
" WHEN @codVdes is not null AND vtb_dest.cod_aliq_in is null and vtb_dest.cod_aliq_out is null and vtb_dest.cod_aliq is null AND anag.cod_aliq is not null then CASE WHEN gtb_aliq.perc_aliq <> 0 THEN anag.cod_aliq ELSE mtb_aart.cod_aliq END /*l'eventuale esenzione deve essere impostata solo l'iva non ha già un'esenzione*/\n" +
|
||||
" WHEN @codVdes is null AND anag.cod_aliq is not null then anag.cod_aliq\n" +
|
||||
" ELSE mtb_aart.cod_aliq \n" +
|
||||
" END\n" +
|
||||
" from mtb_aart left outer join gtb_aliq on mtb_aart.cod_aliq = gtb_aliq.cod_aliq,\n" +
|
||||
" azienda\n" +
|
||||
" left outer join (select cod_anag, cod_aliq from vtb_clie where cod_anag = @codAnag and @gestione = 'V' \n" +
|
||||
" union\n" +
|
||||
" select cod_anag, cod_aliq from atb_forn where cod_anag = @codAnag and @gestione <> 'v' ) anag on anag.cod_anag = @codAnag\n" +
|
||||
" left outer join vtb_dest on anag.cod_anag = vtb_dest.cod_anag and vtb_dest.cod_vdes = @codVdes\n" +
|
||||
" where mtb_aart.cod_mart = @codMart;\n" +
|
||||
"\n" +
|
||||
" -- Return the result of the function\n" +
|
||||
" RETURN @codAliq;\n" +
|
||||
"END");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user