From e9b387e70b361ad7e89efa7904a02ce35026afc8 Mon Sep 17 00:00:00 2001 From: Leeza Baidar Date: Sun, 28 Jan 2024 00:58:29 +0545 Subject: [PATCH] #24827 Promotional Rate setup --- .../proc_countryRateMaster.sql | 142 +++++++----------- 1 file changed, 52 insertions(+), 90 deletions(-) diff --git a/Deployment/24827-Promotional-Rate/proc_countryRateMaster.sql b/Deployment/24827-Promotional-Rate/proc_countryRateMaster.sql index b6e80ac..5697d86 100644 --- a/Deployment/24827-Promotional-Rate/proc_countryRateMaster.sql +++ b/Deployment/24827-Promotional-Rate/proc_countryRateMaster.sql @@ -20,6 +20,7 @@ ALTER PROCEDURE [dbo].[proc_countryRateMaster] @flag VARCHAR(50) = NULL AS SET NOCOUNT ON SET XACT_ABORT ON + BEGIN TRY SET NOCOUNT ON; @@ -79,35 +80,6 @@ BEGIN TRY ,@user ,GETDATE() - --SET @logType = 'Insert' - --SET @oldValue = '' - --SET @newValue = @actualrate + ' | ' + ISNULL(@promRate, '') - --INSERT INTO #msg ( - -- errorCode - -- ,msg - -- ,id - -- ) - --EXEC proc_applicationLogs 'i' - -- ,NULL - -- ,@logType - -- ,@tableAlias - -- ,@countryId - -- ,@user - -- ,@oldValue - -- ,@newValue - --IF EXISTS ( - -- SELECT 'x' - -- FROM #msg - -- WHERE errorCode <> '0' - -- ) - --BEGIN - -- IF @@TRANCOUNT > 0 - -- ROLLBACK TRANSACTION - -- EXEC proc_errorHandler 1 - -- ,'Failed to add new record.' - -- ,@depositType - -- RETURN - --END IF @@TRANCOUNT > 0 COMMIT TRANSACTION @@ -122,8 +94,20 @@ BEGIN TRY AND depositType = @depositType ) BEGIN - SELECT @oldRate = ISNULL(margin, '') - ,@oldPromRate = ISNULL(purchaseRate, '') + INSERT INTO dbo.countryWiseExchangeRateHistory ( + countryId + ,margin + ,purchaseRate + ,modType + ,createdBy + ,createdDate + ) + SELECT countryId + ,margin + ,purchaseRate + ,'UPDATE' + ,@user + ,GETDATE() FROM dbo.countryWiseExchangeRate WHERE countryId = @countryId AND depositType = @depositType @@ -136,50 +120,6 @@ BEGIN TRY WHERE countryId = @countryId AND depositType = @depositType - INSERT INTO dbo.countryWiseExchangeRateHistory( - countryId - ,modType - ,margin - ,purchaseRate - ,createdBy - ,createdDate - ) - SELECT @countryId - ,@depositType - ,'Old value :' + @oldRate + ' | ' + 'New Value :' + @actualrate - ,'Old value :' + @oldPromRate + ' | ' + 'New Value :' + ISNULL(@promRate, '') - ,@user - ,GETDATE() - - --SET @logType = 'Update' - --SET @oldValue = @oldRate + ' | ' + @oldPromRate - --SET @newValue = @actualrate + ' | ' + ISNULL(@promRate, '') - --INSERT INTO #msg ( - -- errorCode - -- ,msg - -- ,id - -- ) - --EXEC proc_applicationLogs 'i' - -- ,NULL - -- ,@logType - -- ,@tableAlias - -- ,@countryId - -- ,@user - -- ,@oldValue - -- ,@newValue - --IF EXISTS ( - -- SELECT 'x' - -- FROM #msg - -- WHERE errorCode <> '0' - -- ) - --BEGIN - -- IF @@TRANCOUNT > 0 - -- ROLLBACK TRANSACTION - -- EXEC proc_errorHandler 1 - -- ,'Failed to add new record.' - -- ,@depositType - -- RETURN - --END IF @@TRANCOUNT > 0 COMMIT TRANSACTION @@ -188,10 +128,8 @@ BEGIN TRY ,@depositType END END - ELSE IF @flag = 'get-list' BEGIN - --SELECT * FROM countryWiseExchangeRate WITH(NOLOCK) WHERE countryId = @countryId IF @sortBy IS NULL SET @sortBy = 'depositType' @@ -233,7 +171,6 @@ BEGIN TRY ,@pageSize ,@pageNumber END - ELSE IF @flag = 'getById' BEGIN SELECT * @@ -241,27 +178,52 @@ BEGIN TRY WHERE countryId = @countryId AND depositType = @depositType END - ELSE IF @flag = 'payment-method' BEGIN - SELECT depositType AS detailTitle, ISNULL(margin,0) as valueId FROM countryWiseExchangeRate WHERE countryId = @countryId + SELECT depositType AS detailTitle + ,ISNULL(margin, 0) AS valueId + FROM countryWiseExchangeRate + WHERE countryId = @countryId END - ELSE IF @flag = 'getListById' BEGIN - SELECT CR.depositType AS detailTitle, CR.margin AS detailDesc + SELECT CR.depositType AS detailTitle + ,CR.margin AS detailDesc FROM dbo.countryWiseExchangeRate CR(NOLOCK) - INNER JOIN countryMaster CM(NOLOCK) on CM.countryId = CR.countryId + INNER JOIN countryMaster CM(NOLOCK) ON CM.countryId = CR.countryId INNER JOIN receiverInformation RI(NOLOCK) ON RI.country = CM.countryName WHERE RI.receiverId = @receiverId END + ELSE IF @flag = 'delete' + BEGIN + BEGIN TRANSACTION + + UPDATE countryWiseExchangeRate + SET isDeleted = 'Y' + ,isActive = 'N' + ,modifiedBy = @user + ,modifiedDate = GETDATE() + WHERE countryId = @countryId + AND depositType = @depositType + + IF @@TRANCOUNT > 0 + COMMIT TRANSACTION + + SELECT 0 error_code + ,'Record deleted successfully.' mes + ,@countryId id + END +END TRY - END TRY BEGIN CATCH - IF @@TRANCOUNT > 0 - ROLLBACK TRANSACTION - DECLARE @errorMessage VARCHAR(MAX) - SET @errorMessage = ERROR_MESSAGE() - EXEC proc_errorHandler 1, @errorMessage, @depositType -END CATCH + IF @@TRANCOUNT > 0 + ROLLBACK TRANSACTION + + DECLARE @errorMessage VARCHAR(MAX) + + SET @errorMessage = ERROR_MESSAGE() + EXEC proc_errorHandler 1 + ,@errorMessage + ,@depositType +END CATCH \ No newline at end of file