Modifica per corretta generazione scadenza di fine mese (febbraio)
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good

This commit is contained in:
2025-12-03 12:14:41 +01:00
parent f697a122b6
commit b3d29219ee

View File

@@ -0,0 +1,46 @@
package it.integry.ems.migration.model;
import it.integry.ems.migration._base.BaseMigration;
import it.integry.ems.migration._base.MigrationModelInterface;
public class Migration_20251203121227 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
createOrUpdateFunction("f_AggiungiGiorniScad", "CREATE FUNCTION [dbo].[f_AggiungiGiorniScad](@dataIniz DateTime, @giorni int, @ls_dataRif varchar(20)) \n" +
"RETURNS dateTime\n" +
" begin\n" +
"\n" +
" declare @ldt_dataInizCalc dateTime\n" +
" DECLARE @mesi INT = @giorni / 30;\n" +
"\n" +
" SELECT @ldt_dataInizCalc = \n" +
" CASE WHEN (@giorni % 30) > 0 OR left(@ls_dataRif, 12) = 'DATA FATTURA' THEN \n" +
" DATEADD(Day, @giorni , @dataIniz )\n" +
" ELSE\n" +
" CASE WHEN @ls_dataRif = 'FINE MESE' AND @giorni = 30 AND Datepart(month, @dataIniz) = 1\n" +
" THEN\n" +
" dbo.f_getLastDayOfMonth(Convert(datetime, Cast(Year(@dataIniz) as varchar) + '/02/01' ))\n" +
" ELSE\n" +
" CASE WHEN (@giorni % 30) = 0 AND @ls_dataRif = 'FINE MESE' AND Datepart(month, @dataIniz) = 12\n" +
" THEN\n" +
" dbo.f_getLastDayOfMonth(DATEADD(Month, @mesi , @dataIniz ))\n" +
" ELSE\n" +
" dbo.f_getLastDayOfMonth(DATEADD(Day, @giorni , @dataIniz ))\n" +
" END \n" +
" END\n" +
" END\n" +
" return (@ldt_dataInizCalc)\n" +
" end;");
}
@Override
public void down() throws Exception {
}
}