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.

134 lines
4.8 KiB

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