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.

173 lines
6.5 KiB

1 year ago
  1. USE [FastMoneyPro_Remit]
  2. GO
  3. /****** Object: StoredProcedure [dbo].[proc_remitTranTempToMain] Script Date: 7/4/2019 11:35:48 AM ******/
  4. DROP PROCEDURE [dbo].[proc_remitTranTempToMain]
  5. GO
  6. /****** Object: StoredProcedure [dbo].[proc_remitTranTempToMain] 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 procEDURE [dbo].[proc_remitTranTempToMain]
  12. @id BIGINT
  13. AS
  14. SET NOCOUNT ON
  15. SET XACT_ABORT ON
  16. BEGIN
  17. BEGIN TRANSACTION
  18. DECLARE @tranId BIGINT
  19. INSERT INTO remitTran(
  20. [holdTranId]
  21. ,[controlNo]
  22. ,[sCurrCostRate],[sCurrHoMargin],[sCurrSuperAgentMargin],[sCurrAgentMargin]
  23. ,[pCurrCostRate],[pCurrHoMargin],[pCurrSuperAgentMargin],[pCurrAgentMargin]
  24. ,[agentCrossSettRate],[customerRate],[sAgentSettRate],[pDateCostRate]
  25. ,[agentFxGain],[treasuryTolerance],[customerPremium],[schemePremium]
  26. ,[sharingValue],[sharingType]
  27. ,[serviceCharge],[handlingFee]
  28. ,[sAgentComm],[sAgentCommCurrency],[sSuperAgentComm],[sSuperAgentCommCurrency]
  29. ,[pAgentComm],[pAgentCommCurrency],[pSuperAgentComm],[pSuperAgentCommCurrency]
  30. ,[promotionCode],[promotionType],[pMessage]
  31. ,[sCountry],[sSuperAgent],[sSuperAgentName],[sAgent],[sAgentName],[sBranch],[sBranchName]
  32. ,[pCountry],[pSuperAgent],[pSuperAgentName],[pAgent],[pAgentName],[pBranch],[pBranchName]
  33. ,[paymentMethod],[pBank],[pBankName],[pBankBranch],[pBankBranchName],[accountNo],[externalBankCode]
  34. ,[collMode]
  35. ,[collCurr],[tAmt],[cAmt],[pAmt],[payoutCurr]
  36. ,[relWithSender],[purposeOfRemit],[sourceOfFund]
  37. ,[tranStatus],[payStatus]
  38. ,[createdDate],[createdDateLocal],[createdBy]
  39. ,[modifiedDate],[modifiedDateLocal],[modifiedBy]
  40. ,[approvedDate],[approvedDateLocal],[approvedBy]
  41. ,[paidDate],[paidDateLocal],[paidBy]
  42. ,[cancelRequestDate],[cancelRequestDateLocal],[cancelRequestBy]
  43. ,[cancelReason],[refund],[cancelCharge]
  44. ,[cancelApprovedDate],[cancelApprovedDateLocal],[cancelApprovedBy]
  45. ,[blockedDate],[blockedBy]
  46. ,[lockedDate],[lockedDateLocal],[lockedBy],[payTokenId]
  47. ,[tranType],[ContNo],[uploadLogId]
  48. ,[voucherNo],[controlNo2]
  49. ,[pBankType],[expectedPayoutAgent]
  50. ,[routedBy],[routedDate],[senderName],[receiverName]
  51. ,[bonusPoint]
  52. ,pState
  53. ,pDistrict, sRouteId,schemeId
  54. )
  55. SELECT
  56. [id]
  57. ,[controlNo]
  58. ,[sCurrCostRate],[sCurrHoMargin],[sCurrSuperAgentMargin],[sCurrAgentMargin]
  59. ,[pCurrCostRate],[pCurrHoMargin],[pCurrSuperAgentMargin],[pCurrAgentMargin]
  60. ,[agentCrossSettRate],[customerRate],[sAgentSettRate],[pDateCostRate]
  61. ,[agentFxGain],[treasuryTolerance],[customerPremium],[schemePremium]
  62. ,[sharingValue],[sharingType]
  63. ,[serviceCharge],[handlingFee]
  64. ,[sAgentComm],[sAgentCommCurrency],[sSuperAgentComm],[sSuperAgentCommCurrency]
  65. ,[pAgentComm],[pAgentCommCurrency],[pSuperAgentComm],[pSuperAgentCommCurrency]
  66. ,[promotionCode],[promotionType],[pMessage]
  67. ,[sCountry],[sSuperAgent],[sSuperAgentName],[sAgent],[sAgentName],[sBranch],[sBranchName]
  68. ,[pCountry],[pSuperAgent],[pSuperAgentName],[pAgent],[pAgentName],[pBranch],[pBranchName]
  69. ,[paymentMethod],[pBank],[pBankName],[pBankBranch],[pBankBranchName],[accountNo],[externalBankCode]
  70. ,[collMode]
  71. ,[collCurr],[tAmt],[cAmt],[pAmt],[payoutCurr]
  72. ,[relWithSender],[purposeOfRemit],[sourceOfFund]
  73. ,[tranStatus],[payStatus]
  74. ,[createdDate],[createdDateLocal],[createdBy]
  75. ,[modifiedDate],[modifiedDateLocal],[modifiedBy]
  76. ,[approvedDate],[approvedDateLocal],[approvedBy]
  77. ,[paidDate],[paidDateLocal],[paidBy]
  78. ,[cancelRequestDate],[cancelRequestDateLocal],[cancelRequestBy]
  79. ,[cancelReason],[refund],[cancelCharge]
  80. ,[cancelApprovedDate],[cancelApprovedDateLocal],[cancelApprovedBy]
  81. ,[blockedDate],[blockedBy]
  82. ,[lockedDate],[lockedDateLocal],[lockedBy],[payTokenId]
  83. ,[tranType],[ContNo],[uploadLogId]
  84. ,[voucherNo],[controlNo2]
  85. ,[pBankType],[expectedPayoutAgent]
  86. ,[routedBy],[routedDate],[senderName],[receiverName]
  87. ,[bonusPoint]
  88. ,pState
  89. ,pDistrict, sRouteId,schemeId
  90. FROM remitTranTemp WITH(NOLOCK) WHERE id = @id
  91. SET @tranId = SCOPE_IDENTITY()
  92. INSERT INTO tranSenders(
  93. [tranId]
  94. ,[holdTranId]
  95. ,[customerId]
  96. ,[membershipId]
  97. ,[firstName],[middleName],[lastName1],[lastName2],[fullName]
  98. ,[country],[address],[state],[district],[zipCode],[city]
  99. ,[email],[homePhone],[workPhone],[mobile]
  100. ,[nativeCountry],[dob],[placeOfIssue]
  101. ,[customerType],[occupation]
  102. ,[idType],[idNumber],[idPlaceOfIssue],[issuedDate],[validDate]
  103. ,[extCustomerId],[cwPwd],[ttName]
  104. ,[isFirstTran],[customerRiskPoint],[countryRiskPoint]
  105. ,[gender],[salary],[companyName],[address2]
  106. ,[dcInfo],[ipAddress],[notifySms],[txnTestQuestion],[txnTestAnswer]
  107. )
  108. SELECT
  109. @tranId
  110. ,[tranId]
  111. ,[customerId]
  112. ,[membershipId]
  113. ,[firstName],[middleName],[lastName1],[lastName2],[fullName]
  114. ,[country],[address],[state],[district],[zipCode],[city]
  115. ,[email],[homePhone],[workPhone],[mobile]
  116. ,[nativeCountry],[dob],[placeOfIssue]
  117. ,[customerType],[occupation]
  118. ,[idType],[idNumber],[idPlaceOfIssue],[issuedDate],[validDate]
  119. ,[extCustomerId],[cwPwd],[ttName]
  120. ,[isFirstTran],[customerRiskPoint],[countryRiskPoint]
  121. ,[gender],[salary],[companyName],[address2]
  122. ,[dcInfo],[ipAddress],[notifySms],[txnTestQuestion],[txnTestAnswer]
  123. FROM tranSendersTemp WITH(NOLOCK) WHERE tranId = @id
  124. INSERT INTO tranReceivers(
  125. [tranId]
  126. ,[holdTranId]
  127. ,[customerId]
  128. ,[membershipId]
  129. ,[firstName],[middleName],[lastName1],[lastName2],[fullName]
  130. ,[country],[address],[state],[district],[zipCode],[city]
  131. ,[email],[homePhone],[workPhone],[mobile]
  132. ,[nativeCountry],[dob],[placeOfIssue]
  133. ,[customerType],[occupation]
  134. ,[idType],[idNumber],[idPlaceOfIssue]
  135. ,[issuedDate],[validDate]
  136. ,[idType2],[idNumber2],[idPlaceOfIssue2],[issuedDate2],[validDate2]
  137. ,[relationType],[relativeName]
  138. ,[gender],[address2]
  139. ,[dcInfo],[ipAddress]
  140. )
  141. SELECT
  142. @tranId
  143. ,[tranId]
  144. ,[customerId]
  145. ,[membershipId]
  146. ,[firstName],[middleName],[lastName1],[lastName2],[fullName]
  147. ,[country],[address],[state],[district],[zipCode],[city]
  148. ,[email],[homePhone],[workPhone],[mobile]
  149. ,[nativeCountry],[dob],[placeOfIssue]
  150. ,[customerType],[occupation]
  151. ,[idType],[idNumber],[idPlaceOfIssue]
  152. ,[issuedDate],[validDate]
  153. ,[idType2],[idNumber2],[idPlaceOfIssue2],[issuedDate2],[validDate2]
  154. ,[relationType],[relativeName]
  155. ,[gender],[address2]
  156. ,[dcInfo],[ipAddress]
  157. FROM tranReceiversTemp WITH(NOLOCK) WHERE tranId = @id
  158. UPDATE bankCollectionVoucherDetail SET mainTranId = @tranId WHERE tempTranId = @id
  159. DELETE FROM remitTranTemp WHERE id = @id
  160. DELETE FROM tranSendersTemp WHERE tranId = @id
  161. DELETE FROM tranReceiversTemp WHERE tranId = @id
  162. COMMIT TRANSACTION
  163. END
  164. GO