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.

180 lines
6.1 KiB

1 year ago
  1. USE [FastMoneyPro_Remit]
  2. GO
  3. /****** Object: StoredProcedure [dbo].[proc_PartnerPinView] Script Date: 7/4/2019 11:35:48 AM ******/
  4. DROP PROCEDURE [dbo].[proc_PartnerPinView]
  5. GO
  6. /****** Object: StoredProcedure [dbo].[proc_PartnerPinView] 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_PartnerPinView] (
  12. @flag CHAR(1)
  13. ,@user VARCHAR(30) = NULL
  14. ,@controlNo VARCHAR(30) = NULL
  15. ,@tranId BIGINT = NULL
  16. ,@lockMode CHAR(1) = NULL
  17. ,@viewType VARCHAR(50) = NULL
  18. ,@viewMsg VARCHAR(MAX) = NULL
  19. )
  20. AS
  21. SET NOCOUNT ON;
  22. SET XACT_ABORT ON;
  23. DECLARE @controlNoEncrypted VARCHAR(100)
  24. IF @flag = 's'
  25. BEGIN
  26. EXEC proc_tranViewHistory 'i', @user, @tranId, @controlNo, NULL,@viewType,@viewMsg
  27. SET @controlNoEncrypted = DBO.FNAENCRYPTSTRING(LTRIM(RTRIM(@controlNo)))
  28. SELECT @tranId = ID FROM REMITTRAN(NOLOCK) WHERE ContNo = @controlNo
  29. IF @tranId IS NULL
  30. SELECT @tranId = ID FROM REMITTRAN(NOLOCK) WHERE ControlNo = @controlNoEncrypted
  31. IF @tranId IS NULL
  32. SELECT @tranId = ID FROM REMITTRAN(NOLOCK) WHERE controlNo2 = @controlNoEncrypted
  33. --Transaction Details
  34. SELECT
  35. tranId = trn.id
  36. ,PartnerPIN = ISNULL(trn.ContNo, '') + ' / '+ dbo.FNADecryptString(trn.controlNo2)
  37. ,controlNo =dbo.FNADecryptString(trn.controlNo)
  38. --Sender Information
  39. ,sMemId = sen.membershipId
  40. ,sCustomerId = sen.customerId
  41. ,senderName = sen.firstName + ISNULL( ' ' + sen.middleName, '') + ISNULL( ' ' + sen.lastName1, '') + ISNULL( ' ' + sen.lastName2, '')
  42. ,sCountryName = trn.sCountry
  43. ,sStateName = sen.state
  44. ,sDistrict = sen.district
  45. ,sCity = isnull(sen.city,'')
  46. ,sAddress = sen.address
  47. ,sContactNo = COALESCE(sen.mobile, sen.homephone, sen.workphone)
  48. ,sIdType = ISNULL(sdv.detailTitle,sen.idType)
  49. ,sIdNo = sen.idNumber
  50. ,sValidDate = sen.validDate
  51. ,sEmail = sen.email
  52. ,extCustomerId = sen.extCustomerId
  53. --Receiver Information
  54. ,rMemId = rec.membershipId
  55. ,rCustomerId = rec.customerId
  56. ,receiverName = rec.firstName + ISNULL( ' ' + rec.middleName, '') + ISNULL( ' ' + rec.lastName1, '') + ISNULL( ' ' + rec.lastName2, '')
  57. ,rCountryName = rec.country
  58. ,rStateName = rec.state
  59. ,rDistrict = rec.district
  60. ,rCity = isnull(rec.city,'')
  61. ,rAddress = rec.address
  62. ,rContactNo = COALESCE(rec.mobile, rec.homephone, rec.workphone)
  63. ,rIdType = ISNULL(rec.idType2, rec.idType)
  64. ,rIdNo = ISNULL(rec.idNumber2, rec.idNumber)+ isnull(' ' + rec.idPlaceOfIssue2,'')
  65. --Sending Agent Information
  66. ,sAgentEmail = sa.agentEmail1
  67. ,sAgentName = CASE WHEN trn.sAgentName = trn.sBranchName THEN '-' ELSE trn.sAgentName END
  68. ,sBranchName = trn.sBranchName
  69. ,sAgentCountry = sa.agentCountry
  70. ,sAgentState = sa.agentState
  71. ,sAgentDistrict = sa.agentDistrict
  72. ,sAgentLocation = sLoc.districtName
  73. ,sAgentCity = sa.agentCity
  74. ,sAgentAddress = sa.agentAddress
  75. --Payout Agent Information
  76. ,pAgentName = case when trn.pAgentName is null then '[Any Where]' else CASE WHEN trn.pAgentName = trn.pBranchName THEN '-' ELSE trn.pAgentName END end
  77. ,pBranchName = trn.pBranchName
  78. ,pAgentCountry = trn.pCountry
  79. ,pAgentState = trn.pState
  80. ,pAgentDistrict = trn.pDistrict
  81. ,pAgentLocation = pLoc.districtName + ISNULL(', ' + ZDM.districtName,'')
  82. ,pAgentCity = pa.agentCity
  83. ,pAgentAddress = pa.agentAddress
  84. ,trn.tAmt
  85. ,trn.serviceCharge
  86. ,handlingFee = ISNULL(trn.handlingFee, 0)
  87. ,sAgentComm = isnull(sAgentComm,0)
  88. ,sAgentCommCurrency = ISNULL(sAgentCommCurrency,0)
  89. ,pAgentComm = ISNULL(pAgentComm,0)
  90. ,pAgentCommCurrency = ISNULL(pAgentCommCurrency,0)
  91. ,exRate = customerRate
  92. ,trn.cAmt
  93. ,pAmt = FLOOR(trn.pAmt)
  94. ,relationship = ISNULL(trn.relWithSender, ' ')+ ISNULL(' '+ rec.relationType,'') + ISNULL(': '+rec.relativeName,'')
  95. ,purpose = ISNULL(trn.purposeOfRemit, '-')
  96. ,sourceOfFund = ISNULL(trn.sourceOfFund, '-')
  97. ,collMode = trn.collMode
  98. ,trn.collCurr
  99. ,paymentMethod = UPPER(trn.paymentMethod)
  100. ,trn.payoutCurr
  101. ,BranchName = trn.pBankBranchName
  102. ,accountNo = trn.accountNo
  103. ,BankName = trn.pBankName
  104. ,tranStatus = CASE when trn.payStatus = 'Post' and trn.tranType='D' then 'Post' else trn.tranStatus end
  105. ,trn.payStatus
  106. ,payoutMsg = ISNULL(trn.pMessage, '-')
  107. ,trn.createdBy
  108. ,trn.createdDate
  109. ,trn.approvedBy
  110. ,trn.approvedDate
  111. ,trn.paidBy
  112. ,trn.paidDate
  113. ,trn.cancelRequestBy
  114. ,trn.cancelRequestDate
  115. ,trn.cancelApprovedBy
  116. ,trn.cancelApprovedDate
  117. ,trn.lockedBy
  118. ,trn.lockedDate
  119. ,trn.payTokenId
  120. ,trn.tranStatus
  121. ,trn.tranType
  122. ,trn.holdTranId
  123. ,sTelNo = ISNULL(sen.homephone, sen.workphone)
  124. ,rTelNo = ISNULL(rec.homephone, rec.workphone)
  125. ,CashOrBank = ''
  126. ,purposeOfRemit = ISNULL(trn.purposeOfRemit, '-')
  127. ,custRate = isnull(customerRate,0) +isnull(schemePremium,0)
  128. ,settRate = agentCrossSettRate
  129. ,nativeCountry = sen.nativeCountry
  130. ,trn.schemePremium AS discount
  131. FROM vwRemitTran trn WITH(NOLOCK)
  132. LEFT JOIN vwTranSenders sen WITH(NOLOCK) ON trn.id = sen.tranId
  133. LEFT JOIN vwTranReceivers rec WITH(NOLOCK) ON trn.id = rec.tranId
  134. LEFT JOIN agentMaster sa WITH(NOLOCK) ON trn.sBranch = sa.agentId
  135. LEFT JOIN agentMaster pa WITH(NOLOCK) ON trn.pBranch = pa.agentId
  136. LEFT JOIN api_districtList pLoc WITH(NOLOCK) ON trn.pLocation = pLoc.districtCode
  137. LEFT JOIN apiLocationMapping ALM WITH(NOLOCK) ON pLoc.districtCode=ALM.apiDistrictCode
  138. LEFT JOIN zoneDistrictMap ZDM WITH(NOLOCK) ON ZDM.districtId=ALM.districtId
  139. LEFT JOIN api_districtList sLoc WITH(NOLOCK) ON sa.agentLocation = sLoc.districtCode
  140. LEFT JOIN staticDataValue sdv WITH(NOLOCK) ON sen.idType=CAST(sdv.valueId AS VARCHAR)
  141. WHERE trn.ID = LTRIM(RTRIM(@tranId))
  142. --End of Transaction Details------------------------------------------------------------
  143. --Log Details---------------------------------------------------------------------------
  144. SELECT
  145. rowId
  146. ,message
  147. ,trn.createdBy
  148. ,trn.createdDate
  149. ,isnull(trn.fileType,'')fileType
  150. FROM tranModifyLog trn WITH(NOLOCK)
  151. LEFT JOIN applicationUsers au WITH(NOLOCK) ON trn.createdBy = au.userName
  152. WHERE trn.tranId = LTRIM(RTRIM(@tranId))
  153. ORDER BY trn.rowId DESC
  154. SELECT
  155. bankName = 'Cash'
  156. ,collMode = 'Cash'
  157. ,amt = ''
  158. ,collDate = ''
  159. ,voucherNo = ''
  160. ,narration = 'Cash Collection'
  161. END
  162. GO