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.

157 lines
11 KiB

11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
  1. USE [FastMoneyPro_Remit]
  2. GO
  3. /****** Object: StoredProcedure [dbo].[proc_online_sendIntlReceipt] Script Date: 10/19/2023 6:21:32 PM ******/
  4. SET ANSI_NULLS ON
  5. GO
  6. SET QUOTED_IDENTIFIER ON
  7. GO
  8. ALTER PROC [dbo].[proc_online_sendIntlReceipt] (
  9. @flag VARCHAR(50)
  10. ,@user VARCHAR(200) = NULL
  11. ,@tranId INT = NULL
  12. ,@fltAmount VARCHAR(20) = NULL
  13. ,@intStatus VARCHAR(200) = NULL
  14. )
  15. AS
  16. --------------------------------------------------------
  17. --#101 - Mobile Changes
  18. --Hide control number for unapproved Txn
  19. --------------------------------------------------------
  20. SET NOCOUNT ON;
  21. IF @flag = 'receipt' --All transaction information (sender, receiver, payout)
  22. BEGIN
  23. SELECT '0' ErrorCode, 'Send Transaction Success - Receipt' Msg
  24. SELECT
  25. tranId = ISNULL(trn.holdTranId, trn.id)
  26. ,controlNo = CASE WHEN trn.approvedDate IS NULL THEN ' ' ELSE dbo.FNADecryptString(trn.controlNo) END
  27. --Sender Information
  28. ,sMemId = sen.membershipId
  29. ,sCustomerId = sen.customerId
  30. ,senderName = sen.firstName + ISNULL( ' ' + sen.middleName, '') + ISNULL( ' ' + sen.lastName1, '') + ISNULL( ' ' + sen.lastName2, '')
  31. ,sCountryName = sen.country
  32. ,sNativeCountry=sen.nativeCountry
  33. ,sAddress = sen.address
  34. ,sContactNo = COALESCE(sen.mobile, sen.homephone, sen.workphone)
  35. ,sIdType = sen.idType
  36. ,sIdNo = sen.idNumber
  37. ,Email = sen.email
  38. ,sPostalCode = sen.zipcode
  39. ,sCity = sen.city
  40. ,companyName = sen.companyName
  41. --Receiver Information
  42. ,rMemId = rec.membershipId
  43. ,idExpiry = CONVERT(VARCHAR,sen.validDate,101)
  44. ,rCustomerId = rec.customerId
  45. ,receiverName = rec.firstName + ISNULL( ' ' + rec.middleName, '') + ISNULL( ' ' + rec.lastName1, '') + ISNULL( ' ' + rec.lastName2, '')
  46. ,rCountryName = rec.country
  47. ,rAddress = rec.address
  48. ,rContactNo = COALESCE(rec.mobile, rec.homephone, rec.workphone)
  49. ,rIdType = rec.idType
  50. ,rIdNo = rec.idNumber
  51. ,relWithSender = trn.relWithSender
  52. ,rCity = rec.city
  53. ,rec.firstName AS rFirstName
  54. ,rec.middleName AS rMiddleName
  55. ,rec.lastName1 + ISNULL( ' ' + rec.lastName2, '') AS rLastName
  56. ,rec.email AS rEmail
  57. ,rec.state AS rState
  58. --Sending Agent Information
  59. ,sAgentName = CASE WHEN trn.sAgentName = trn.sBranchName THEN trn.sSuperAgentName ELSE trn.sAgentName END
  60. ,sBranchName = trn.sBranchName
  61. ,sAgentCountry = sa.agentCountry
  62. ,headMsg = sa.headMessage
  63. ,sAgentLocation = sLoc.districtName
  64. ,sAgentAddress = sa.agentAddress
  65. ,agentPhone1 = sa.agentPhone1
  66. --Payout Agent Information
  67. ,pAgentCountry = trn.pCountry
  68. ,trn.sCountry
  69. ,pAgent = ISNULL(trn.pBankName, trn.pAgentName)
  70. ,sPremium = ISNULL(ROUND((tAmt * schemePremium) / customerRate, 4),0)
  71. ,exRatePremium = ISNULL(schemePremium,0)
  72. ,pPremium = ISNULL((tAmt * schemePremium),0)
  73. ,premiumDisc = 0
  74. ,trn.collMode
  75. ,trn.tAmt
  76. ,trn.serviceCharge
  77. ,handlingFee = ISNULL(trn.handlingFee, 0)
  78. ,netServiceCharge = serviceCharge
  79. ,totalServiceCharge = serviceCharge + ISNULL(handlingFee, 0)
  80. ,perAmt = '1'
  81. ,scAmt2 = serviceCharge - ISNULL(trn.handlingFee, 0)
  82. ,exRate = customerRate + ISNULL(schemePremium, 0)
  83. ,trn.cAmt
  84. ,trn.pAmt
  85. ,trn.paymentMethod
  86. ,trn.accountNo
  87. ,paymentMode = CASE trn.paymentMethod WHEN 'Cash Payment' THEN 'Cash Pay' WHEN 'Bank Deposit' THEN 'Bank Transfer' ELSE trn.paymentMethod END
  88. ,stm.category
  89. ,pBankName = CASE WHEN trn.paymentMethod = 'Cash Payment' THEN '[ANY WHERE] - ' + trn.pCountry ELSE trn.pBankName END
  90. ,pBranchName = trn.pBankBranchName
  91. ,BankName = trn.pBankName
  92. ,BranchName = trn.pBankBranchName
  93. ,headMsg = sa.headMessage
  94. ,trn.accountNo
  95. ,trn.pCountry
  96. ,relationship = ISNULL(trn.relWithSender, '')
  97. ,purpose = ISNULL(trn.purposeOfRemit, '')
  98. ,sourceOfFund = ISNULL(trn.sourceOfFund, '')
  99. ,occupation = ISNULL(sen.occupation,'')
  100. ,collMode = trn.collMode
  101. ,trn.collCurr
  102. ,paymentMethod = trn.paymentMethod
  103. ,trn.payoutCurr
  104. ,payStatus
  105. ,tranStatus = CASE WHEN trn.tranStatus='Reject' then 'DECLINED'
  106. WHEN trn.tranStatus='Cancel' then 'CANCELLED'
  107. WHEN trn.tranStatus='paid' then 'PAID'
  108. WHEN depositType = 'ONLINE' AND trn.verifiedDate IS NULL THEN 'PENDING'
  109. WHEN depositType ='DEBIT_CARD' AND trn.verifiedDate IS NOT NULL THEN 'PROCESSING'
  110. WHEN depositType in('ONLINE','DEBIT_CARD') AND trn.verifiedDate IS NOT NULL THEN 'PROCESSING'
  111. else UPPER(payStatus) end
  112. ,payoutMsg = ISNULL(trn.pMessage, '')
  113. ,trn.createdBy
  114. --,createdDate = dbo.FNADateFormatTZ(trn.createdDate,trn.createdBy)
  115. ,createdDate = trn.createdDate
  116. ,trn.approvedBy
  117. ,trn.approvedDate
  118. ,trn.paidBy
  119. ,trn.paidDate
  120. ,trn.payTokenId
  121. ,trn.createdDateLocal
  122. ,'' [schemeAction]
  123. ,trn.handlingFee [schemeFee]
  124. ,[custStatus] = 'Active'
  125. ---- add new fields
  126. ,couponName =''
  127. ,discountType = ''
  128. ,discountValue = ''
  129. ,discountPercent = ''
  130. ,DisplayActions = CASE WHEN trn.tranStatus='Payment' THEN 'CANCEL'+','+'AMEND' ELSE '' END
  131. ,rewardPoints
  132. FROM vwRemitTran trn WITH(NOLOCK)
  133. INNER JOIN vwTranSenders sen WITH(NOLOCK) ON trn.id = sen.tranId
  134. INNER JOIN vwTranReceivers rec WITH(NOLOCK) ON trn.id = rec.tranId
  135. LEFT JOIN serviceTypeMaster stm WITH(NOLOCK) ON trn.paymentMethod = stm.typeTitle
  136. LEFT JOIN agentMaster sa WITH(NOLOCK) ON trn.sBranch = sa.agentId
  137. LEFT JOIN agentMaster pa WITH(NOLOCK) ON trn.pBranch = pa.agentId
  138. LEFT JOIN api_districtList sLoc WITH(NOLOCK) ON sa.agentLocation = sLoc.districtCode
  139. --LEFT JOIN schemeSetup SCH WITH (NOLOCK) ON SCH.rowId = trn.SchemeId
  140. WHERE trn.id = @tranId or trn.holdTranId = @tranId
  141. END