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.

109 lines
8.5 KiB

1 year ago
  1. USE [FastMoneyPro_Remit]
  2. GO
  3. /****** Object: StoredProcedure [dbo].[proc_pushSendToInficare] 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_pushSendToInficare]
  9. AS
  10. IF EXISTS(SELECT TOP 1 'X' FROM domesticSendQueueList WITH(NOLOCK))
  11. BEGIN
  12. DECLARE @controlNoList TABLE(controlNo VARCHAR(30), controlNoSwiftEnc VARCHAR(30), controlNoInficareEnc VARCHAR(30))
  13. INSERT INTO @controlNoList(controlNo, controlNoSwiftEnc, controlNoInficareEnc)
  14. SELECT controlNo, controlNoSwiftEnc, controlNoInficareEnc FROM domesticSendQueueList WITH(NOLOCK)
  15. INSERT hremit.dbo.moneySend(
  16. refno
  17. ,agentid
  18. ,agentname
  19. ,district_code
  20. ,district_name
  21. ,SenderName
  22. ,SenderAddress,SenderPhoneno,SenderCity,SenderCountry
  23. ,receiverPassport
  24. ,ReceiverName
  25. ,ReceiverAddress,ReceiverPhone,ReceiverCountry
  26. ,DOT, DOtTime, paidAmt, paidCType, receiveAmt, receiveCType,SCharge
  27. ,ReciverMessage
  28. ,paymentType
  29. ,rBankID
  30. ,rBankName
  31. ,rBankBranch
  32. ,otherCharge
  33. ,TransStatus, status, SEmpID
  34. ,TotalRoundAmt,senderCommission,receivercommission
  35. ,ext_commission, approve_by, confirmdate, local_dot
  36. ,receiveAgentID, bank_id,bank_branch_name,bank_account_detail
  37. ,digital_id_sender,id_type,id_no,email,relation,ReceiverCity
  38. )
  39. SELECT
  40. refno = st.controlNoInficareEnc
  41. ,agentid = sbm.mapCodeDom
  42. ,agentname = CASE WHEN sbm.agentType = 2904 THEN sam.agentName ELSE adl.districtName END
  43. ,district_code = sbm.agentLocation
  44. ,district_name = sl.districtName
  45. ,SenderName = UPPER(sen.firstName + ISNULL(' ' + sen.middleName, '') + ISNULL(' ' + sen.lastName1, '') + ISNULL(' ' + sen.lastName2, ''))
  46. ,SenderAddress = sen.[address]
  47. ,SenderPhoneno = COALESCE(sen.mobile, sen.homePhone, sen.workPhone)
  48. ,SenderCity = sen.city
  49. ,SenderCountry = sen.country
  50. ,receiverPassport = rec.idNumber
  51. ,ReceiverName = UPPER(rec.firstName + ISNULL(' ' + rec.middleName, '') + ISNULL(' ' + rec.lastName1, '') + ISNULL(' ' + rec.lastName2, ''))
  52. ,ReceiverAddress = rec.[address]
  53. ,ReceiverPhone = COALESCE(sen.mobile, sen.homePhone, sen.workPhone)
  54. ,ReceiverCountry = rec.country
  55. ,DOT = rt.createdDate
  56. ,DotTime = CONVERT(VARCHAR,rt.createdDate,108)
  57. ,paidAmt = rt.cAmt
  58. ,paidCType = 'NPR'
  59. ,receiveAmt = rt.pAmt
  60. ,receiveCType = 'NPR'
  61. ,SCharge = rt.serviceCharge
  62. ,ReciverMessage = rec.idType
  63. ,paymentType = CASE WHEN rt.paymentMethod = 'Cash Payment' THEN 'Cash Pay' WHEN rt.paymentMethod = 'Bank Deposit' THEN 'Bank Transfer' END
  64. ,rBankId = had.agentCode
  65. ,rBankName = ISNULL(bank_name,adl.districtName)
  66. ,rBankBranch = ISNULL(bbm.agentAddress,adl.districtName)
  67. ,otherCharge = 0
  68. ,TransStatus = 'Payment'
  69. ,status = 'Un-Paid'
  70. ,SEmpID = 'S:' + rt.createdBy
  71. ,TotalRoundAmt = rt.pAmt
  72. ,senderCommission = rt.sAgentComm
  73. ,receiverCommission = rt.pAgentComm
  74. ,ext_commission = 0.00
  75. ,approve_by = 'S:' + rt.createdBy
  76. ,confirmdate = rt.createdDate
  77. ,local_dot = rt.createdDate
  78. ,receiveAgentID = rt.pLocation
  79. ,bank_id = had.bank_id
  80. ,bank_branch_name = rt.pBankName
  81. ,bank_account_detail = rt.accountNo
  82. ,digital_id_sender = 'swift_api'
  83. ,id_type = sen.idType
  84. ,id_no = sen.idNumber
  85. ,email = sen.email
  86. ,relation = rt.relWithSender
  87. ,ReceiverCity = rec.city
  88. FROM remitTran rt WITH(NOLOCK)
  89. INNER JOIN tranSenders sen WITH(NOLOCK) ON rt.id = sen.tranId
  90. INNER JOIN tranReceivers rec WITH(NOLOCK) ON rt.id = rec.tranId
  91. INNER JOIN @controlNoList st ON rt.controlNo = st.controlNoSwiftEnc
  92. INNER JOIN agentMaster sbm WITH(NOLOCK) ON rt.sBranch = sbm.agentId
  93. INNER JOIN agentMaster sam WITH(NOLOCK) ON sbm.parentId = sam.agentId
  94. INNER JOIN api_districtList adl WITH(NOLOCK) ON rt.pLocation = adl.districtCode
  95. LEFT JOIN api_districtList sl WITH(NOLOCK) ON sbm.agentLocation = sl.districtCode
  96. LEFT JOIN agentMaster bm WITH(NOLOCK) ON rt.pBank = bm.agentId
  97. LEFT JOIN hremit.dbo.agentDetail had WITH(NOLOCK) ON bm.mapCodeDom = had.agentCode
  98. LEFT JOIN hremit.dbo.bank_detail bd WITH(NOLOCK) ON had.bank_id = bd.bank_id
  99. LEFT JOIN agentMaster bbm WITH(NOLOCK) ON rt.pBankBranch = bbm.agentId
  100. DELETE FROM domesticSendQueueList
  101. FROM domesticSendQueueList sl
  102. INNER JOIN @controlNoList cnl ON sl.controlNo = cnl.controlNo
  103. END
  104. GO