Merge branch 'hotfix/Hotfix-1'
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good

This commit is contained in:
2025-10-31 12:19:28 +01:00

View File

@@ -0,0 +1,49 @@
package it.integry.ems.migration.model;
import it.integry.ems.migration._base.BaseMigration;
import it.integry.ems.migration._base.MigrationModelInterface;
public class Migration_20251031120553 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
createOrUpdateFunction("f_suggestEAN13","CREATE FUNCTION [dbo].[f_suggestEAN13](@precode VARCHAR(12))\n" +
" RETURNS VARCHAR(13)\n" +
" AS\n" +
" BEGIN\n" +
"\n" +
" DECLARE @ean13 VARCHAR(13);\n" +
"\n" +
" IF LEN(@precode) = 12\n" +
" BEGIN\n" +
" SELECT @ean13 = CONCAT(@precode, dbo.getCheckDigitEan13(@precode))\n" +
" END;\n" +
" ELSE\n" +
" BEGIN\n" +
" WITH ean AS (SELECT MAX(CAST((RIGHT(\n" +
" LEFT(cod_barre, LEN(cod_barre) - 1),\n" +
" (LEN(cod_barre) - LEN(@precode) - 1))) AS NUMERIC)) AS maxValue\n" +
"\n" +
" FROM mvw_barcode\n" +
" WHERE cod_barre LIKE @precode + '%'\n" +
" AND LEN(cod_barre) = 13\n" +
" AND ISNUMERIC(RIGHT(cod_barre, LEN(cod_barre) - LEN(@precode))) = 1)\n" +
" SELECT @ean13 = CONCAT(@precode,\n" +
" RIGHT(FORMAT((ISNULL(maxValue, 0) + 1), REPLICATE('0', 12)), 12 - LEN(@precode)))\n" +
" FROM ean;\n" +
"\n" +
" SELECT @ean13 = CONCAT(@ean13, dbo.getCheckDigitEan13(@ean13))\n" +
"\n" +
"\n" +
" END\n" +
" RETURN @ean13;\n" +
" END\n");
}
@Override
public void down() throws Exception {
}
}