You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

139 lines
3.8 KiB

1 year ago
  1. USE [FastMoneyPro_Remit]
  2. GO
  3. /****** Object: StoredProcedure [dbo].[proc_online_complianceCheck] Script Date: 7/4/2019 11:35:48 AM ******/
  4. DROP PROCEDURE [dbo].[proc_online_complianceCheck]
  5. GO
  6. /****** Object: StoredProcedure [dbo].[proc_online_complianceCheck] Script Date: 7/4/2019 11:35:48 AM ******/
  7. SET ANSI_NULLS ON
  8. GO
  9. SET QUOTED_IDENTIFIER ON
  10. GO
  11. CREATE PROC [dbo].[proc_online_complianceCheck]
  12. (
  13. @flag VARCHAR(50)
  14. , @user VARCHAR(100)
  15. , @senderId VARCHAR(50) = NULL
  16. , @benId VARCHAR(50) = NULL
  17. , @rMobile VARCHAR(20) = NULL
  18. , @raccountNo VARCHAR(50) = NULL
  19. , @pCountryId INT = NULL
  20. , @deliveryMethod VARCHAR(50) = NULL
  21. , @deliveryMethodId INT = NULL
  22. , @sBranch INT = NULL
  23. , @pBranch INT = NULL
  24. , @agentRefId VARCHAR(50) = NULL
  25. , @collCurr VARCHAR(3) = NULL
  26. , @sIdType VARCHAR(30) = NULL
  27. , @sIdNo VARCHAR(25) = NULL
  28. , @rfName VARCHAR(80) = NULL
  29. , @cAmt MONEY = NULL
  30. , @sCountry VARCHAR(30) = NULL
  31. , @pCountry VARCHAR(30) = NULL
  32. , @sMobile VARCHAR(25) = NULL
  33. , @senderName VARCHAR(100)
  34. )
  35. AS
  36. SET NOCOUNT ON;
  37. SET XACT_ABORT ON;
  38. BEGIN TRY
  39. BEGIN
  40. DECLARE @pStateId INT
  41. ,@totalRows INT
  42. ,@count INT
  43. ,@id INT
  44. ,@tAmt MONEY = NULL
  45. ,@csMasterId INT
  46. ,@complianceRes VARCHAR(20)
  47. ,@collModeDesc VARCHAR(50)
  48. ,@compFinalRes VARCHAR(20)
  49. ,@errorCode VARCHAR(5)
  50. ,@msg VARCHAR(MAX)
  51. IF @collCurr <> 'GBP'
  52. BEGIN
  53. SET @sBranch = '32916';
  54. END;
  55. ELSE
  56. BEGIN
  57. SET @sBranch = '32915';
  58. END;
  59. IF @flag = 'complianceCheck'
  60. BEGIN
  61. DECLARE @complianceRuleId INT, @complienceMessage VARCHAR(1000), @shortMsg VARCHAR(150), @complienceErrorCode INT
  62. EXEC [proc_complianceRuleDetail]
  63. @user = @user
  64. ,@sIdType = @sIdType
  65. ,@sIdNo = @sIdNo
  66. ,@receiverName = @rfName
  67. ,@cAmt = @cAmt
  68. ,@country = @sCountry
  69. ,@message = @complienceMessage OUTPUT
  70. ,@shortMessage = @shortMsg OUTPUT
  71. ,@errCode = @complienceErrorCode OUTPUT
  72. ,@ruleId = @complianceRuleId OUTPUT
  73. IF(@complienceErrorCode <> 0)
  74. BEGIN
  75. IF(@complienceErrorCode = 1)
  76. BEGIN
  77. SET @errorCode=101
  78. --SELECT 101 errorCode,@msg msg, @complienceErrorCode id, @complienceMessage compApproveRemark,'compliance' vtype
  79. END
  80. ELSE
  81. BEGIN
  82. SET @errorCode=102
  83. INSERT remitTranComplianceTemp(csDetailTranId, matchTranId, agentRefId)
  84. SELECT @complianceRuleId, NULL, @agentRefId
  85. --SELECT 102 errorCode,@msg msg, @complienceErrorCode id, @complienceMessage compApproveRemark,'compliance' vtype
  86. END
  87. INSERT INTO ComplianceLog(senderName, senderCountry, senderIdType, senderIdNumber, senderMobile, receiverName, receiverCountry, payOutAmt,
  88. complianceId, complianceReason, complainceDetailMessage, createdBy, createdDate, logType)
  89. SELECT @senderName, @sCountry, @sIdType, @sIdNo, @sMobile, @rfName, @pCountry, @cAmt, @complianceRuleId, @shortMsg, @complienceMessage, @user, GETDATE(),
  90. 'online'
  91. DECLARE @tempRowId INT = @@IDENTITY
  92. SELECT @errorCode errorCode
  93. ,complianceReason msg
  94. , id
  95. ,CASE WHEN @errorCode=102 THEN 'HOLD' ELSE 'Blocked' END vtype
  96. FROM ComplianceLog
  97. WHERE id = @tempRowId
  98. --SELECT
  99. -- @errorCode
  100. -- ,csDetailRecId = ''
  101. -- ,[S.N.] = ROW_NUMBER()OVER(ORDER BY id)
  102. -- ,[Remarks] = complianceReason
  103. -- ,[Action] = CASE WHEN @complienceErrorCode=102 THEN 'HOLD' ELSE 'Blocked' END
  104. ----,[Matched Tran ID] = ''
  105. --FROM ComplianceLog
  106. --WHERE id = @tempRowId
  107. RETURN
  108. END
  109. ELSE
  110. BEGIN
  111. SELECT 0 errorCode,'Success' msg, 0 id
  112. END
  113. END
  114. END
  115. END TRY
  116. BEGIN CATCH
  117. IF @@TRANCOUNT<>0
  118. ROLLBACK TRANSACTION
  119. DECLARE @errorMessage VARCHAR(MAX)
  120. SET @errorMessage = ERROR_MESSAGE()
  121. EXEC proc_errorHandler 1, @errorMessage, @user
  122. END CATCH
  123. GO