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.

135 lines
7.0 KiB

1 year ago
  1. USE [FastMoneyPro_Remit]
  2. GO
  3. /****** Object: StoredProcedure [dbo].[proc_releaseComplianceTxn] Script Date: 9/27/2019 1:30:14 PM ******/
  4. SET ANSI_NULLS ON
  5. GO
  6. SET QUOTED_IDENTIFIER ON
  7. GO
  8. CREATE proc [dbo].[proc_releaseComplianceTxn]
  9. @flag VARCHAR(50) = NULL
  10. ,@user VARCHAR(200) = NULL
  11. ,@controlNo VARCHAR(100) = NULL
  12. ,@sBranchName VARCHAR(100) = NULL
  13. ,@sortBy VARCHAR(50) = NULL
  14. ,@sortOrder VARCHAR(5) = NULL
  15. ,@pageSize INT = NULL
  16. ,@pageNumber INT = NULL
  17. ,@Msg VARCHAR(20) = NULL
  18. AS
  19. /*
  20. [proc_releaseComplianceTxn] @flag = 's' ,@pageNumber='1', @pageSize='10', @sortBy='sBranchName', @sortOrder='asc', @user = 'netra'
  21. */
  22. SET NOCOUNT ON;
  23. SET XACT_ABORT ON;
  24. BEGIN TRY
  25. DECLARE
  26. @sql VARCHAR(MAX)
  27. ,@table VARCHAR(MAX)
  28. ,@select_field_list VARCHAR(MAX)
  29. ,@extra_field_list VARCHAR(MAX)
  30. ,@sql_filter VARCHAR(MAX)
  31. IF @flag='s'
  32. BEGIN
  33. SET @table = '
  34. (
  35. SELECT tranId = rt.id
  36. ,controlNo=dbo.fnadecryptstring(rt.controlNo)
  37. ,rt.sBranchName
  38. ,rt.createdBy
  39. ,rt.createdDate
  40. ,rt.pAmt
  41. ,type = ''OFAC''
  42. ,receiverName = receiverName
  43. ,senderName = senderName
  44. FROM remitTran rt WITH(NOLOCK)
  45. INNER JOIN remitTranOfac ofac with(nolock) on rt.id = ofac.tranId
  46. WHERE (rt.tranStatus = ''Hold'' OR rt.tranStatus = ''OFAC Hold'' OR rt.tranStatus = ''OFAC/Compliance Hold'') AND createdDate > ''2015-01-01''
  47. AND rt.tranType = ''D'' and ofac.approvedDate is null
  48. UNION ALL
  49. SELECT DISTINCT tranId = rt.id
  50. ,controlNo=dbo.fnadecryptstring(rt.controlNo)
  51. ,rt.sBranchName
  52. ,rt.createdBy
  53. ,rt.createdDate
  54. ,rt.pAmt
  55. ,type = ''Compliance''
  56. ,receiverName = receiverName
  57. ,senderName = senderName
  58. FROM remitTran rt WITH(NOLOCK)
  59. INNER JOIN remitTranCompliance comp with(nolock) on rt.id = comp.tranId
  60. WHERE (rt.tranStatus = ''Hold'' OR rt.tranStatus = ''Compliance Hold'' OR rt.tranStatus = ''OFAC/Compliance Hold'') AND createdDate > ''2015-01-01''
  61. AND rt.tranType = ''D'' and comp.approvedDate is null)
  62. '
  63. IF @sortBy IS NULL
  64. SET @sortBy = 'createdDate'
  65. IF @sortOrder IS NULL
  66. SET @sortOrder = 'ASC'
  67. SET @table = '(
  68. select
  69. tranId
  70. ,controlNo= ''<a href="'+dbo.FNAGetURL()+'Remit/Transaction/ApproveOFAC/ComplianceDom/Manage.aspx?controlNo='' + main.controlNo + ''">'' + main.controlNo + ''</a>''
  71. ,type
  72. ,receiverName
  73. ,senderName
  74. ,sBranchName
  75. ,createdBy
  76. ,createdDate
  77. ,pAmt
  78. ,hasChanged = ''''
  79. FROM ' + @table + ' main
  80. ) x'
  81. SET @sql_filter = ''
  82. IF @controlNo IS NOT NULL
  83. SET @sql_filter = @sql_filter + ' AND controlNo LIKE ''%' + @controlNo + '%'''
  84. IF @sBranchName IS NOT NULL
  85. SET @sql_filter = @sql_filter + ' AND sBranchName LIKE ''' + @sBranchName + '%'''
  86. SET @select_field_list ='
  87. controlNo
  88. ,sBranchName
  89. ,type
  90. ,receiverName
  91. ,senderName
  92. ,hasChanged
  93. ,createdBy
  94. ,createdDate
  95. ,pAmt
  96. ,tranId
  97. '
  98. EXEC dbo.proc_paging
  99. @table
  100. ,@sql_filter
  101. ,@select_field_list
  102. ,@extra_field_list
  103. ,@sortBy
  104. ,@sortOrder
  105. ,@pageSize
  106. ,@pageNumber
  107. END
  108. END TRY
  109. BEGIN CATCH
  110. IF @@TRANCOUNT > 0
  111. ROLLBACK TRANSACTION
  112. DECLARE @errorMessage VARCHAR(MAX)
  113. SET @errorMessage = ERROR_MESSAGE()
  114. EXEC proc_errorHandler 1, @errorMessage, @controlNo
  115. END CATCH
  116. GO