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.

201 lines
13 KiB

1 year ago
  1. USE [FastMoneyPro_Remit]
  2. GO
  3. /****** Object: StoredProcedure [dbo].[proc_transactionViewEduPay] Script Date: 9/27/2019 1:30:14 PM ******/
  4. SET ANSI_NULLS ON
  5. GO
  6. SET QUOTED_IDENTIFIER ON
  7. GO
  8. ALTER proc [dbo].[proc_transactionViewEduPay] (
  9. @flag VARCHAR(50)
  10. ,@user VARCHAR(30) = NULL
  11. ,@controlNo VARCHAR(30) = NULL
  12. ,@tranId BIGINT = NULL
  13. ,@message VARCHAR(500) = NULL
  14. ,@messageComplaince VARCHAR(500) = NULL
  15. ,@messageOFAC VARCHAR(500) = NULL
  16. ,@lockMode CHAR(1) = NULL
  17. ,@viewType VARCHAR(50) = NULL
  18. ,@viewMsg VARCHAR(MAX) = NULL
  19. ,@branch INT = NULL
  20. ,@sortBy VARCHAR(50) = NULL
  21. ,@sortOrder VARCHAR(5) = NULL
  22. ,@pageSize INT = NULL
  23. ,@pageNumber INT = NULL
  24. )
  25. AS
  26. SET @controlNo = UPPER(@controlNo)
  27. IF @tranId IS NULL
  28. SELECT @tranId=id FROM remitTran WHERE controlNo=dbo.FNAEncryptString(@controlNo)
  29. DECLARE
  30. @select_field_list VARCHAR(MAX)
  31. ,@extra_field_list VARCHAR(MAX)
  32. ,@table VARCHAR(MAX)
  33. ,@sql_filter VARCHAR(MAX)
  34. DECLARE @controlNoEncrypted VARCHAR(100)
  35. ,@code VARCHAR(50)
  36. ,@userName VARCHAR(50)
  37. ,@password VARCHAR(50)
  38. SET NOCOUNT ON
  39. SET XACT_ABORT ON
  40. IF @flag = 's'
  41. BEGIN
  42. DECLARE @tranStatus VARCHAR(20)
  43. SELECT @controlNoEncrypted = dbo.FNAEncryptString(UPPER(LTRIM(RTRIM(@controlNo))))
  44. --Transaction View History--------------------------------------------------------------------------------------
  45. EXEC proc_tranViewHistory 'i', @user, @tranId, @controlNo, NULL,@viewType,@viewMsg
  46. --End-----------------------------------------------------------------------------------------------------------
  47. --Transaction Details------------------------------------------------------------
  48. SELECT
  49. tranId = trn.id
  50. ,controlNo = dbo.FNADecryptString(trn.controlNo)
  51. --Sender Information
  52. ,sMemId = sen.membershipId
  53. ,sCustomerId = sen.customerId
  54. ,senderName = sen.firstName + ISNULL( ' ' + sen.middleName, '') + ISNULL( ' ' + sen.lastName1, '') + ISNULL( ' ' + sen.lastName2, '')
  55. ,sCountryName = sen.country
  56. ,sStateName = sen.state
  57. ,sDistrict = sen.district
  58. ,sCity = sen.city
  59. ,sAddress = sen.address
  60. ,sContactNo = COALESCE(sen.mobile, sen.homephone, sen.workphone)
  61. ,sIdType = sen.idType
  62. ,sIdNo = sen.idNumber
  63. ,sValidDate = sen.validDate
  64. ,sEmail = sen.email
  65. ,extCustomerId = sen.extCustomerId
  66. --Receiver Information
  67. ,rMemId = rec.membershipId
  68. ,rCustomerId = rec.customerId
  69. ,receiverName = rec.firstName + ISNULL( ' ' + rec.middleName, '') + ISNULL( ' ' + rec.lastName1, '') + ISNULL( ' ' + rec.lastName2, '')
  70. ,rCountryName = rec.country
  71. ,rStateName = rec.state
  72. ,rDistrict = rec.district
  73. ,rCity = rec.city
  74. ,rAddress = rec.address
  75. ,rContactNo = COALESCE(rec.mobile, rec.homephone, rec.workphone)
  76. ,rIdType = ISNULL(rec.idType, rec.idType2)
  77. ,rIdNo = ISNULL(rec.idNumber, rec.idNumber2)
  78. --Sending Agent Information
  79. ,sAgentName = CASE WHEN trn.sAgentName = trn.sBranchName THEN '-' ELSE trn.sAgentName END
  80. ,sBranchName = trn.sBranchName
  81. ,sAgentCountry = sa.agentCountry
  82. ,sAgentState = sa.agentState
  83. ,sAgentDistrict = sa.agentDistrict
  84. ,sAgentLocation = sLoc.districtName
  85. ,sAgentCity = sa.agentCity
  86. ,sAgentAddress = sa.agentAddress
  87. --Payout Agent Information
  88. ,pAgentName = CASE WHEN trn.pAgentName = trn.pBranchName THEN '-' ELSE trn.pAgentName END
  89. ,pBranchName = trn.pBranchName
  90. ,pAgentCountry = trn.pCountry
  91. ,pAgentState = trn.pState
  92. ,pAgentDistrict = trn.pDistrict
  93. ,pAgentLocation = pLoc.districtName + ISNULL(', ' + ZDM.districtName,'')
  94. ,pAgentCity = pa.agentCity
  95. ,pAgentAddress = pa.agentAddress
  96. ,trn.tAmt
  97. ,trn.serviceCharge
  98. ,handlingFee = ISNULL(trn.handlingFee, 0)
  99. ,sAgentComm = isnull(sAgentComm,0)
  100. ,sAgentCommCurrency = ISNULL(sAgentCommCurrency,0)
  101. ,pAgentComm = ISNULL(pAgentComm,0)
  102. ,pAgentCommCurrency = ISNULL(pAgentCommCurrency,0)
  103. ,exRate = customerRate
  104. ,trn.cAmt
  105. ,trn.pAmt
  106. ,relationship = ISNULL(trn.relWithSender, '-')
  107. ,purpose = ISNULL(trn.purposeOfRemit, '-')
  108. ,sourceOfFund = ISNULL(trn.sourceOfFund, '-')
  109. ,collMode = trn.collMode
  110. ,trn.collCurr
  111. ,paymentMethod = trn.paymentMethod
  112. ,trn.payoutCurr
  113. ,BranchName = trn.pBankBranchName
  114. ,trn.accountNo
  115. ,BankName = trn.pBankName
  116. ,trn.tranStatus
  117. ,trn.payStatus
  118. ,payoutMsg = ISNULL(trn.pMessage, '-')
  119. ,trn.createdBy
  120. ,trn.createdDate
  121. ,trn.approvedBy
  122. ,trn.approvedDate
  123. ,trn.paidBy
  124. ,trn.paidDate
  125. ,trn.cancelRequestBy
  126. ,trn.cancelRequestDate
  127. ,trn.cancelApprovedBy
  128. ,trn.cancelApprovedDate
  129. ,trn.lockedBy
  130. ,trn.lockedDate
  131. ,trn.payTokenId
  132. ,trn.tranStatus
  133. ,trn.tranType
  134. ,stdName
  135. ,stdLevel = sl.name
  136. ,stdRollRegNo
  137. ,stdSemYr = dbo.FNAGetDataValue(stdSemYr)
  138. ,stdCollegeId
  139. ,feeTypeId = sf.feeType
  140. FROM remitTran trn WITH(NOLOCK)
  141. LEFT JOIN tranSenders sen WITH(NOLOCK) ON trn.id = sen.tranId
  142. LEFT JOIN tranReceivers rec WITH(NOLOCK) ON trn.id = rec.tranId
  143. LEFT JOIN agentMaster sa WITH(NOLOCK) ON trn.sBranch = sa.agentId
  144. LEFT JOIN agentMaster pa WITH(NOLOCK) ON trn.pBranch = pa.agentId
  145. LEFT JOIN api_districtList pLoc WITH(NOLOCK) ON trn.pLocation = pLoc.districtCode
  146. LEFT JOIN apiLocationMapping ALM WITH(NOLOCK) ON pLoc.districtCode=ALM.apiDistrictCode
  147. LEFT JOIN zoneDistrictMap ZDM WITH(NOLOCK) ON ZDM.districtId=ALM.districtId
  148. LEFT JOIN api_districtList sLoc WITH(NOLOCK) ON sa.agentLocation = sLoc.districtCode
  149. left join schoolFee sf with(nolock) on sf.rowId = rec.feeTypeId
  150. left join schoolLevel sl with(nolock) on sl.rowId = rec.stdLevel
  151. WHERE trn.controlNo = @controlNoEncrypted OR trn.id = LTRIM(RTRIM(@tranId))
  152. --End of Transaction Details------------------------------------------------------------
  153. --Lock Transaction----------------------------------------------------------------------
  154. IF (@lockMode = 'Y')
  155. BEGIN
  156. UPDATE remitTran SET
  157. tranStatus = 'Lock'
  158. ,lockedBy = @user
  159. ,lockedDate = GETDATE()
  160. ,lockedDateLocal = dbo.FNADateFormatTZ(GETDATE(), @user)
  161. WHERE (tranStatus = 'Payment' AND tranStatus <> 'CancelRequest')
  162. AND payStatus = 'Unpaid' AND (controlNo = @controlNoEncrypted OR id = LTRIM(RTRIM(@tranId)))
  163. END
  164. --End of Lock Transaction---------------------------------------------------------------
  165. --Log Details---------------------------------------------------------------------------
  166. SELECT
  167. rowId
  168. ,message
  169. ,trn.createdBy
  170. ,trn.createdDate
  171. ,isnull(trn.fileType,'')fileType
  172. FROM tranModifyLog trn WITH(NOLOCK)
  173. LEFT JOIN applicationUsers au WITH(NOLOCK) ON trn.createdBy = au.userName
  174. WHERE trn.tranId = LTRIM(RTRIM(@tranId)) --OR trn.controlNo = @controlNoEncrypted
  175. ORDER BY trn.createdDate DESC
  176. END
  177. GO