Gestione esenzione iva su spese trasporto da prospet
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_20250923132435 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
|
||||
createOrUpdateFunction("f_getCodEsenz", "CREATE FUNCTION [dbo].[f_getCodEsenz](@gestione varchar(1), @codAnag varchar(5), @codVdes varchar(5))\n" +
|
||||
"RETURNS varchar(5) \n" +
|
||||
"AS\n" +
|
||||
"BEGIN\n" +
|
||||
" DECLARE @ls_codAliqCli VARCHAR(5),\n" +
|
||||
" @ls_codAliqForn VARCHAR(5),\n" +
|
||||
" @ls_codAliqIn VARCHAR(5),\n" +
|
||||
" @ls_codAliqOut VARCHAR(5),\n" +
|
||||
" @ls_codesenz VARCHAR(5),\n" +
|
||||
" @existCodAnag INTEGER;\n" +
|
||||
" \n" +
|
||||
" SELECT @existCodAnag = 0\n" +
|
||||
" SELECT @ls_codAliqCli = vtb_clie.cod_aliq,\n" +
|
||||
" @ls_codAliqForn = atb_forn.cod_aliq,\n" +
|
||||
" @ls_codAliqIn = vtb_dest.cod_aliq_in,\n" +
|
||||
" @ls_codAliqOut = vtb_dest.cod_aliq_out,\n" +
|
||||
" @existCodAnag = 1\n" +
|
||||
" FROM gtb_anag LEFT OUTER JOIN vtb_clie ON vtb_clie.cod_anag = gtb_anag.cod_anag\n" +
|
||||
" LEFT OUTER JOIN atb_forn ON atb_forn.cod_anag = @codAnag\n" +
|
||||
" LEFT OUTER JOIN vtb_dest ON vtb_dest.cod_vdes = @codVdes AND\n" +
|
||||
" vtb_dest.cod_anag = @codAnag\n" +
|
||||
" WHERE gtb_anag.cod_anag = @codAnag;\n" +
|
||||
"\n" +
|
||||
" IF @gestione = 'V' and @existCodAnag = 0\n" +
|
||||
" begin\n" +
|
||||
" select @ls_codAliqIn = ptb_dest.cod_aliq_in,\n" +
|
||||
" @ls_codAliqOut = ptb_dest.cod_aliq_out\n" +
|
||||
" from ptb_dest \n" +
|
||||
" where cod_ppro = @codAnag AND\n" +
|
||||
" cod_pdes = @codVdes;\n" +
|
||||
" end\n" +
|
||||
" \n" +
|
||||
" if @ls_codAliqIn is null and @ls_codAliqOut is not null\n" +
|
||||
" SELECT @ls_codesenz = @ls_codAliqOut\n" +
|
||||
" \n" +
|
||||
" if @gestione <>'V'\n" +
|
||||
" SELECT @ls_codAliqCli = @ls_codAliqForn\n" +
|
||||
" \n" +
|
||||
" if @ls_codesenz is null and @ls_codAliqCli is not null \n" +
|
||||
" SELECT @ls_codEsenz = @ls_codAliqCli\n" +
|
||||
" \n" +
|
||||
" RETURN @ls_codEsenz;\n" +
|
||||
"END");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user