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.

171 lines
10 KiB

1 year ago
  1. USE [FastMoneyPro_Remit]
  2. GO
  3. /****** Object: StoredProcedure [dbo].[proc_payIntTxnManual] Script Date: 9/27/2019 1:30:14 PM ******/
  4. SET ANSI_NULLS ON
  5. GO
  6. SET QUOTED_IDENTIFIER ON
  7. GO
  8. /*
  9. exec proc_payIntTxnManual @flag ='payTran',@user ='sheela123',@pBranch = '1247'
  10. */
  11. CREATE proc [dbo].[proc_payIntTxnManual] (
  12. @flag VARCHAR(50)
  13. ,@user VARCHAR(30) = NULL
  14. ,@pBranch INT = NULL
  15. ,@controlNo VARCHAR(20) = NULL
  16. ,@agentRefId VARCHAR(20) = NULL
  17. ,@rIdType VARCHAR(30) = NULL
  18. ,@rIdNumber VARCHAR(30) = NULL
  19. ,@rPlaceOfIssue VARCHAR(50) = NULL
  20. ,@rMobile VARCHAR(100) = NULL
  21. ,@rRelationType VARCHAR(50) = NULL
  22. ,@rRelativeName VARCHAR(100) = NULL
  23. ,@membershipId VARCHAR(50) = NULL
  24. ,@customerId VARCHAR(50) = NULL
  25. )
  26. AS
  27. SET NOCOUNT ON
  28. SET XACT_ABORT ON
  29. DECLARE
  30. @sCountry VARCHAR(200)
  31. ,@sCountryId INT
  32. ,@sBranch INT
  33. ,@sAgent INT
  34. ,@sSuperAgent INT
  35. ,@sSuperAgentName VARCHAR(100)
  36. ,@sLocation INT
  37. ,@pSuperAgent INT
  38. ,@pSuperAgentName VARCHAR(100)
  39. ,@pAgent INT
  40. ,@pAgentName VARCHAR(100)
  41. ,@pBranchName VARCHAR(100)
  42. ,@pCountry VARCHAR(100)
  43. ,@pCountryId INT
  44. ,@pState VARCHAR(100)
  45. ,@pDistrict VARCHAR(100)
  46. ,@pLocation INT
  47. ,@deliveryMethod VARCHAR(100)
  48. ,@deliveryMethodId INT
  49. ,@pAmt MONEY
  50. ,@cAmt MONEY
  51. ,@pAgentComm MONEY
  52. ,@pAgentCommCurrency VARCHAR(3)
  53. ,@pSuperAgentComm MONEY
  54. ,@pSuperAgentCommCurrency VARCHAR(3)
  55. ,@pHubComm MONEY
  56. ,@pHubCommCurrency VARCHAR(3)
  57. ,@collMode INT
  58. ,@receivingCurrency INT
  59. ,@senderId INT
  60. ,@agentType INT
  61. ,@actAsBranchFlag CHAR(1)
  62. ,@tokenId BIGINT
  63. ,@controlNoEncrypted VARCHAR(20)
  64. ,@mapCodeInt VARCHAR(20)
  65. ,@commCheck MONEY
  66. ,@settlingAgent int
  67. ,@userId int
  68. ,@tranId BIGINT
  69. ,@serviceCharge MONEY
  70. ,@sRouteId VARCHAR(5)
  71. ,@lockStatus VARCHAR(10)
  72. SELECT @controlNo = UPPER(LTRIM(RTRIM(@controlNo)))
  73. SELECT @controlNoEncrypted = dbo.FNAEncryptString(@controlNo)
  74. /*
  75. SELECT agentType,actAsbranch,* FROM agentMaster with(nolock) where agentId =1247
  76. select * from applicationUsers with(nolock) where agentId = 1247 --sheela123
  77. */
  78. IF @flag = 'payTran'
  79. BEGIN
  80. SELECT TOP 150 * INTO #TEMP_TXN
  81. FROM RemittanceLogData.dbo.unpaidTxn with(nolock) where IS_PAID is null and flag is null
  82. --drop table #TEMP_TXN
  83. --SELECT * FROM RemittanceLogData.dbo.unpaidTxn
  84. BEGIN TRANSACTION
  85. UPDATE remitTran SET
  86. pAgentComm = (SELECT ISNULL(amount, 0)
  87. FROM dbo.FNAGetPayComm(B.sBranch, B.sCountryId, B.sLocation, B.pSuperAgent, B.pCountryId, B.pLocation, B.pBranch, 'NPR',
  88. B.deliveryMethodId, B.cAmt, B.pAmt, B.serviceCharge, NULL, NULL)
  89. )
  90. ,pAgentCommCurrency = 'NPR'
  91. ,pBranch = '1247'
  92. ,pBranchName = 'IME EXCHANGE COUNTER (A)'
  93. ,pAgent = '1247'
  94. ,pAgentName = 'IME EXCHANGE COUNTER (A)'
  95. ,pSuperAgent = '1002'
  96. ,pSuperAgentName = 'INTERNATIONAL MONEY EXPRESS (IME) PVT. LTD'
  97. ,pCountry = 'Nepal'
  98. ,pState = 'Bagmati'
  99. ,pLocation = '137'
  100. ,pDistrict = 'Bagmati'
  101. ,tranStatus = 'Paid'
  102. ,payStatus = 'Paid'
  103. ,paidDate = dbo.FNAGetDateInNepalTZ()
  104. ,paidDateLocal = GETDATE()
  105. ,paidBy = 'sheela123'
  106. ,lockStatus = 'unlocked'
  107. ,voucherNo = 'SYSTEM'
  108. FROM remitTran A,
  109. (
  110. select TOP 150
  111. controlNo = up.encryptedControlNo,
  112. sBranch = rt.sBranch,
  113. sCountryId = sam.agentCountryId,
  114. sLocation = sam.agentLocation,
  115. pSuperAgent = 1002,
  116. pCountryId = 151,
  117. pLocation = 137,
  118. pBranch = 1247,
  119. deliveryMethodId = 1,
  120. cAmt = rt.cAmt,
  121. pAmt = rt.pAmt,
  122. serviceCharge = rt.serviceCharge
  123. from #TEMP_TXN up with(nolock)
  124. inner join remitTran rt with(nolock) on up.encryptedControlNo = rt.controlNO
  125. left join agentMaster sam with(nolock) on sam.agentId = rt.sBranch
  126. where rt.tranStatus = 'Payment'
  127. )B WHERE A.controlNo =B.controlNo
  128. UPDATE RemittanceLogData.dbo.unpaidTxn SET IS_PAID = 'Y'
  129. WHERE encryptedControlNo IN (SELECT encryptedControlNo FROM #TEMP_TXN)
  130. declare @txnCount varchar(50),@msg varchar(max)
  131. select @txnCount = count('x') from #TEMP_TXN
  132. drop table #TEMP_TXN
  133. /*
  134. select rt.tranStatus,rt.payStatus from remitTran rt with(nolock) inner join #TEMP_TXN t on rt.controlNo = t.encryptedControlNo
  135. */
  136. IF @@TRANCOUNT > 0
  137. COMMIT TRANSACTION
  138. set @msg = @txnCount+' Transaction(s) has been paid successfully.'
  139. EXEC [proc_errorHandler] 0, @msg, @controlNo
  140. END
  141. /*
  142. select * from remitTran with(nolock) where pAgent = 1247 and paidDate > '2014-08-18'
  143. and tranType='I' and sBranch is null
  144. update remitTran set sAgent ='20398',sBranch='20398' where pAgent = 1247 and paidDate > '2014-08-17'
  145. and tranType='I' and sAgentName='City Exchange'
  146. select * from remitTran with(nolock) where pAgent = 1247,sBranch= and paidDate > '2014-08-13'
  147. and tranType='I' and sAgentName='Islamic Exchange'
  148. select agentType,actasbranch,* from agentMaster with(nolock) where agentName like '%City Exchange%'
  149. select * from agentMaster with(nolock) where agentId = 20398
  150. */
  151. GO