20240903075550_GeneralLedgerBalanceAlertsMail_NotificationDefinition_New

--FileName:20240903075550_GeneralLedgerBalanceAlertsMail_NotificationDefinition--

--TenantsToBeExecuted:all--

/*

* The file has been generated from Catalog (tenantless).

* Generated time: 09/03/2024 07:55:50

* Generated machine: fi-notification-api-56bf699768-tv6x6

* Generator user: app

*/


 

BEGIN


 

DECLARE @OutputIdsTableForNotificationDefinition TABLE (Id INT)


 

IF NOT EXISTS (SELECT * FROM dbo.NotificationDefinition WHERE NotificationCode=N'GeneralLedgerBalanceAlertsMail')

BEGIN

INSERT INTO dbo.NotificationDefinition([CanCompensate],[CompensateNotificationDefinitionId],[ContentType],[CreatedBy],[CreateTime],[Description],[ExpireDuration],[IsCompensateNotification],[IsCritical],[IsEncrypted],[Name],[NotificationCode],[ServiceUniqueName],[TargetType],[UpdateCount],[UpdatedBy],[UpdateTime])

VALUES (0, NULL, 1, N'system', GETDATE(), N'Mizan ile muavin uyumsuz kayıtları mail atar.', 54, 0, 0, 0, N'Mizan ile muavin uyumsuz kayıtları mail atar', N'GeneralLedgerBalanceAlertsMail', N'Accounting', 4, 0, NULL, NULL)

END

ELSE

BEGIN

UPDATE dbo.NotificationDefinition SET [CanCompensate] = 0, [CompensateNotificationDefinitionId] = NULL, [ContentType] = 1, [Description] = N'Mizan ile muavin uyumsuz kayıtları mail atar.', [ExpireDuration] = 54, [HasSensitiveData] = NULL, [IsCompensateNotification] = 0, [IsCritical] = 0, [IsEncrypted] = 0, [Name] = N'Mizan ile muavin uyumsuz kayıtları mail atar', [NotificationCode] = N'GeneralLedgerBalanceAlertsMail', [ServiceUniqueName] = N'Accounting', [TargetType] = 4, [UpdateCount] = UpdateCount + 1, [UpdatedBy] = N'system', [UpdateTime] = GETDATE()

WHERE NotificationCode=N'GeneralLedgerBalanceAlertsMail'

END




 

INSERT INTO @OutputIdsTableForNotificationDefinition SELECT Id FROM dbo.NotificationDefinition WHERE NotificationCode = 'GeneralLedgerBalanceAlertsMail'


 

DECLARE @masterTabletemplateMaxVersion int =0


 

DECLARE @OutputIdsTableForNotificationDefinitionTranslation TABLE (Id INT)


 

-- ********** NotificationCode(GeneralLedgerBalanceAlertsMail). Deleting all old details in the table and inserting new ones for this record. **********


 

DELETE dbo.NotificationDefinitionTranslation

FROM dbo.NotificationDefinitionTranslation d

INNER JOIN dbo.NotificationDefinition m ON m.Id=d.NotificationDefinitionId

WHERE m.NotificationCode=N'GeneralLedgerBalanceAlertsMail'


 

DECLARE @masterTableIdValueFor_96A3F7F_GeneralLedgerBalanceAlertsMail INT

SELECT @masterTableIdValueFor_96A3F7F_GeneralLedgerBalanceAlertsMail=Id FROM dbo.NotificationDefinition WHERE NotificationCode=N'GeneralLedgerBalanceAlertsMail'




 

INSERT INTO dbo.NotificationDefinitionTranslation([Description],[LanguageCode],[Name],[NotificationDefinitionId])

OUTPUT INSERTED.Id INTO @OutputIdsTableForNotificationDefinitionTranslation(Id)

VALUES (N'Fiş mizan farklarını mail atar.', N'eng', N'GeneralLedgerBalanceAlerts', @masterTableIdValueFor_96A3F7F_GeneralLedgerBalanceAlertsMail)




 

INSERT INTO dbo.NotificationDefinitionTranslation([Description],[LanguageCode],[Name],[NotificationDefinitionId])

OUTPUT INSERTED.Id INTO @OutputIdsTableForNotificationDefinitionTranslation(Id)

VALUES (N'Fiş mizan farklarını mail atar.', N'fra', N'GeneralLedgerBalanceAlerts', @masterTableIdValueFor_96A3F7F_GeneralLedgerBalanceAlertsMail)




 

INSERT INTO dbo.NotificationDefinitionTranslation([Description],[LanguageCode],[Name],[NotificationDefinitionId])

OUTPUT INSERTED.Id INTO @OutputIdsTableForNotificationDefinitionTranslation(Id)

VALUES (N'Fiş mizan farklarını mail atar.', N'rus', N'GeneralLedgerBalanceAlerts', @masterTableIdValueFor_96A3F7F_GeneralLedgerBalanceAlertsMail)




 

INSERT INTO dbo.NotificationDefinitionTranslation([Description],[LanguageCode],[Name],[NotificationDefinitionId])

OUTPUT INSERTED.Id INTO @OutputIdsTableForNotificationDefinitionTranslation(Id)

VALUES (N'Mizan ile muavin uyumsuz kayıtları mail atar.', N'tur', N'Mizan ile muavin uyumsuz kayıtları mail atar', @masterTableIdValueFor_96A3F7F_GeneralLedgerBalanceAlertsMail)




 

DECLARE @OutputIdsTableForOtpPolicy TABLE (Id INT)


 

SELECT top 1 @masterTabletemplateMaxVersion= Version

FROM dbo.NotificationTemplate

WHERE 1=1 AND ChannelType= 1 AND LanguageId= 166 AND NotificationDefinitionId= (SELECT TOP 1 Id FROM @OutputIdsTableForNotificationDefinition)AND IsLatestVersion = 1 ORDER BY Id DESC


 

SET @masterTabletemplateMaxVersion=@masterTabletemplateMaxVersion +1


 

UPDATE dbo.NotificationTemplate SET IsLatestVersion = 0 WHERE 1=1 AND ChannelType= 1 AND LanguageId= 166 AND NotificationDefinitionId= (SELECT TOP 1 Id FROM @OutputIdsTableForNotificationDefinition)


 

BEGIN

IF NOT EXISTS (SELECT * FROM dbo.NotificationTemplate WHERE 1=1 AND ChannelType= 1 AND LanguageId= 166 AND NotificationDefinitionId= (SELECT TOP 1 Id FROM @OutputIdsTableForNotificationDefinition) AND IsLatestVersion = 1)

BEGIN

INSERT INTO dbo.NotificationTemplate([BCC],[CC],[ChannelType],[Content],[CreatedBy],[CreateTime],[IsLatestVersion],[LanguageId],[MaximumRetryCount],[NotificationDefinitionId],[SkipBlocking],[Subject],[TO],[Type],[UpdateCount],[UpdatedBy],[UpdateTime],[Version])

VALUES (N'', N'', 1, N'<p>@#c.Differencelist@# </p>', N'system', GETDATE(), 1, 166, 5, (SELECT TOP 1 Id FROM @OutputIdsTableForNotificationDefinition), 0, N'@#c.TenantUniqueName@# - @#c.Env@# - @#c.Subject@# - @#c.Count@# İşlem - @#c.Date@# ', N'[email protected]', NULL, 0, NULL, NULL, @masterTabletemplateMaxVersion)

END

ELSE

BEGIN

PRINT('template has already been updated')

END

END




 

END