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.

743 lines
52 KiB

1 year ago
  1. USE [FastMoneyPro_Remit]
  2. GO
  3. /****** Object: StoredProcedure [dbo].[proc_payCompliance] 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 procEDURE [dbo].[proc_payCompliance](
  9. @flag VARCHAR(20)
  10. ,@user VARCHAR(50) = NULL
  11. ,@id INT = NULL
  12. ,@remarks VARCHAR(MAX) = NULL
  13. ,@controlNo VARCHAR(50) = NULL
  14. ,@csDetailRecId BIGINT = NULL
  15. ,@sortBy VARCHAR(50) = NULL
  16. ,@sortOrder VARCHAR(5) = NULL
  17. ,@pageSize INT = NULL
  18. ,@pageNumber INT = NULL
  19. )
  20. AS
  21. SET NOCOUNT ON
  22. SET XACT_ABORT ON
  23. BEGIN TRY
  24. DECLARE @tranId BIGINT
  25. IF @flag='txn_list'
  26. BEGIN
  27. DECLARE
  28. @sql VARCHAR(MAX)
  29. ,@table VARCHAR(MAX)
  30. ,@select_field_list VARCHAR(MAX)
  31. ,@extra_field_list VARCHAR(MAX)
  32. ,@sql_filter VARCHAR(MAX)
  33. SET @table = '
  34. (
  35. SELECT TOP 10
  36. provider = CASE WHEN rtc.provider =''4734'' THEN ''Global Remit''
  37. WHEN rtc.provider =''4670'' THEN ''Cash Express''
  38. WHEN rtc.provider =''4726'' THEN ''EZ Remit''
  39. WHEN rtc.provider =''4869'' THEN ''RIA Remit''
  40. WHEN rtc.provider =''4854'' THEN ''MoneyGram''
  41. WHEN rtc.provider =''4909'' THEN ''Xpress Mone''
  42. WHEN rtc.provider =''4816'' THEN ''Instant Cash''
  43. WHEN rtc.provider =''4812'' THEN ''IME-I''
  44. WHEN rtc.provider =''1002'' THEN ''IME-D''
  45. ELSE ''-'' END
  46. ,tranId = rtc.TranId
  47. ,controlNo = ''<a href="'+dbo.FNAGetURL()+'Remit/Transaction/ApproveOFAC/PayTranCompliance/Manage.aspx?rowId='' + cast(rtc.rowId as varchar) + ''">'' +dbo.fnadecryptstring(rtc.controlNo)+ ''</a>''
  48. ,pBranchName = am.agentName
  49. ,receiverName = receiverName
  50. ,type = ''Compliance''
  51. ,createdBy = rtc.createdBy
  52. ,createdDate = rtc.createdDate
  53. ,hasChanged = ''''
  54. FROM tranPayCompliance rtc WITH(NOLOCK)
  55. LEFT JOIN dbo.agentMaster am WITH(NOLOCK) ON rtc.pBranch = am.agentId
  56. WHERE rtc.approvedDate IS NULL '
  57. IF @controlNo IS NOT NULL
  58. SET @table = @table + ' AND rtc.controlNo LIKE ''%' + dbo.fnaencryptstring(@controlNo) + '%'''
  59. SET @table = @table + ' )x'
  60. SET @sortBy = 'createdDate'
  61. IF @sortOrder IS NULL
  62. SET @sortOrder = 'ASC'
  63. SET @sql_filter = ''
  64. SET @select_field_list ='
  65. controlNo
  66. ,pBranchName
  67. ,type
  68. ,receiverName
  69. ,hasChanged
  70. ,createdBy
  71. ,createdDate
  72. ,tranId
  73. ,provider
  74. '
  75. EXEC dbo.proc_paging
  76. @table
  77. ,@sql_filter
  78. ,@select_field_list
  79. ,@extra_field_list
  80. ,@sortBy
  81. ,@sortOrder
  82. ,@pageSize
  83. ,@pageNumber
  84. END
  85. IF @Flag='s'
  86. BEGIN
  87. DECLARE
  88. @agentGrp INT,
  89. @partnerId BIGINT,
  90. @branchName VARCHAR(200),
  91. @rowId BIGINT
  92. SELECT @partnerId = provider,
  93. @rowId = tranId
  94. FROM tranPayCompliance WITH(NOLOCK)
  95. WHERE rowId = @id
  96. IF @partnerId IS NULL
  97. BEGIN
  98. EXEC proc_errorHandler 1, 'Invalid Transaction.', @rowId
  99. RETURN;
  100. END
  101. IF(@partnerId='4734') /***** Global Remit *****/
  102. BEGIN
  103. EXEC proc_errorHandler 0, 'Transaction varification successfully.', @rowId
  104. SELECT TOP 1
  105. rowId = gbl.rowId
  106. ,securityNo = dbo.FNADecryptString(gbl.radNo)
  107. ,transactionDate = gbl.createdDate
  108. ,senderName = gbl.senderName
  109. ,senderAddress = gbl.senderAddress
  110. ,senderMobile = gbl.senderMobile
  111. ,senderTel = gbl.senderTel
  112. ,senderIdNo = gbl.senderIdNo
  113. ,senderIdType = gbl.senderIdType
  114. ,senderCity = ''
  115. ,recName = gbl.benefName
  116. ,recAddress = gbl.benefAddress
  117. ,recMobile = gbl.benefMobile
  118. ,recTelePhone = gbl.benefTel
  119. ,recIdType = gbl.benefIdType
  120. ,recIdNo = gbl.benefAccIdNo
  121. ,recCity = ''
  122. ,recCountry = ''
  123. ,pAmount = gbl.amount
  124. ,rCurrency = gbl.rCurrency
  125. ,pCurrency = gbl.pCurrency
  126. ,remarks = gbl.remarks
  127. ,paymentMethod = 'Cash Payment'
  128. ,tokenId = gbl.tokenId
  129. ,amt = gbl.amount
  130. ,pBranch = gbl.pBranch
  131. ,sendingCountry = ''
  132. ,sendingAgent = ''
  133. ,branchName = am.agentName
  134. ,providerName = 'Global Remit'
  135. ,orderNo = ''
  136. FROM globalBankPayHistory gbl WITH(NOLOCK)
  137. LEFT JOIN dbo.agentMaster am WITH(NOLOCK) ON gbl.pBranch = am.agentId
  138. WHERE rowId = @rowId ORDER BY rowId DESC
  139. --## Transaction Log Details
  140. SELECT TOP 1
  141. rowId
  142. ,message
  143. ,trn.createdBy
  144. ,trn.createdDate
  145. FROM tranModifyLog trn WITH(NOLOCK) WHERE 1=2
  146. RETURN
  147. END
  148. IF (@partnerId='4670') /***** CASH EXPRESS *****/
  149. BEGIN
  150. EXEC proc_errorHandler 0, 'Transaction varification successfully.', @rowId
  151. SELECT TOP 1
  152. rowId
  153. ,securityNo = dbo.FNADecryptString(ce.gitNo)
  154. ,transactionDate = ce.createdDate
  155. ,senderName = ce.custName
  156. ,senderAddress = ISNULL(ce.custAddress,'')
  157. ,senderMobile = ISNULL(ce.custPhone,'')
  158. ,senderTel = ''
  159. ,senderIdNo = ce.custIdNo
  160. ,senderIdType = ce.custIdType
  161. ,senderCity = ''
  162. ,recName = ce.beneName
  163. ,recAddress = ce.beneAddress
  164. ,recMobile = isnull(ce.rContactNo,ce.benePhone)
  165. ,recTelePhone = ISNULL(ce.benePhone,'')
  166. ,recIdType = ce.rIdType
  167. ,recIdNo = ce.rIdNumber
  168. ,recCity = ''
  169. ,recCountry = ''
  170. ,pAmount = ce.destinationAmount
  171. ,rCurrency = 'NPR'
  172. ,pCurrency = ce.destinationCurrency
  173. ,remarks = ce.remarks
  174. ,paymentMethod = 'Cash Payment'
  175. ,tokenId = ''
  176. ,amt = ce.destinationAmount
  177. ,pBranch = ce.pBranch
  178. ,sendingCountry = ''
  179. ,sendingAgent = ''
  180. ,branchName = am.agentName
  181. ,providerName = 'Cash Express'
  182. ,orderNo = ''
  183. FROM cePayHistory ce WITH(NOLOCK)
  184. LEFT JOIN dbo.agentMaster am WITH(NOLOCK) ON ce.pBranch = am.agentId
  185. WHERE rowId = @rowId ORDER BY rowId DESC
  186. --## Transaction Log Details
  187. SELECT TOP 1
  188. rowId
  189. ,message
  190. ,trn.createdBy
  191. ,trn.createdDate
  192. FROM tranModifyLog trn WITH(NOLOCK) WHERE 1=2
  193. RETURN
  194. END
  195. IF (@partnerId='4726') /***** EZ Remit *****/
  196. BEGIN
  197. EXEC proc_errorHandler 0, 'Transaction varification successfully.', @rowId
  198. SELECT TOP 1
  199. rowId = ez.id
  200. ,securityNo = dbo.FNADecryptString(ez.SecurityNumber)
  201. ,transactionDate = ez.createdDate
  202. ,senderName = ez.scCustomerName
  203. ,senderAddress = ISNULL(ez.scCustomerAddress,'')
  204. ,senderMobile = ISNULL(ez.scCustMobileNumber,'')
  205. ,senderTel = ISNULL(ez.scCustTelephoneNumber,'')
  206. ,senderIdNo = ez.scCustId
  207. ,senderIdType = ez.scCustIdType
  208. ,senderCity = ''
  209. ,recName = ez.tbName
  210. ,recAddress = ez.tbAddress
  211. ,recMobile = isnull(rContactNo,ez.tbContactTelephoneNo)
  212. ,recTelePhone = ISNULL(ez.tbContactTelephoneNo,'')
  213. ,recIdType = ez.rIdType
  214. ,recIdNo = ez.rIdNumber
  215. ,recCity = ''
  216. ,recCountry = ez.tbBenCountry
  217. ,pAmount = ez.tdFxAmount
  218. ,rCurrency = 'NPR'
  219. ,pCurrency = ez.tdFxCurrencyCode
  220. ,remarks = ez.remarks
  221. ,paymentMethod = 'Cash Payment'
  222. ,tokenId = ''
  223. ,amt = ez.tdFxAmount
  224. ,pBranch = ez.pBranch
  225. ,sendingCountry = ez.scCustCountry
  226. ,sendingAgent = ez.scCustBankName
  227. ,branchName = am.agentName
  228. ,providerName = 'EZ Remit'
  229. ,orderNo = ''
  230. FROM ezPayHistory ez WITH(NOLOCK)
  231. LEFT JOIN dbo.agentMaster am WITH(NOLOCK) ON ez.pBranch = am.agentId
  232. WHERE ez.id = @rowId
  233. ORDER BY id DESC
  234. --## Transaction Log Details
  235. SELECT TOP 1
  236. rowId
  237. ,message
  238. ,trn.createdBy
  239. ,trn.createdDate
  240. FROM tranModifyLog trn WITH(NOLOCK) WHERE 1=2
  241. RETURN
  242. END
  243. IF (@partnerId='4869') /***** RIA *****/
  244. BEGIN
  245. EXEC proc_errorHandler 0, 'Transaction varification successfully.', @rowId
  246. SELECT TOP 1
  247. rowId
  248. ,securityNo = dbo.FNADecryptString(ria.pin)
  249. ,transactionDate = ria.createdDate
  250. ,senderName = ria.CustNameFirst + ISNULL( ' ' + ria.custNameLast1, '') + ISNULL( ' ' + ria.custNameLast2, '')
  251. ,senderAddress = ISNULL(ria.CustAddress,'')
  252. ,senderMobile = ISNULL(ria.custTelNo,'')
  253. ,senderTel = ISNULL(ria.custTelNo,'')
  254. ,senderIdNo = ''
  255. ,senderIdType = ''
  256. ,senderCity = ''
  257. ,recName = ria.beneNameFirst + ISNULL( ' ' + ria.beneNameLast1, '') + ISNULL( ' ' + ria.beneNameLast2, '')
  258. ,recAddress = ria.rAddress
  259. ,recMobile = ISNULL(ria.rContactNo,'')
  260. ,recTelePhone = ISNULL(ria.rContactNo,'')
  261. ,recIdType = ria.rIdType
  262. ,recIdNo = ria.rIdNumber
  263. ,recCity = ''
  264. ,recCountry = ''
  265. ,pAmount = ria.BeneAmount
  266. ,rCurrency = 'NPR'
  267. ,pCurrency = 'NPR'
  268. ,remarks = ria.remarks
  269. ,paymentMethod = 'Cash Payment'
  270. ,tokenId = ria.transRefID
  271. ,amt = ria.beneAmount
  272. ,pBranch = ria.pBranch
  273. ,sendingCountry = ''
  274. ,sendingAgent = ''
  275. ,branchName = am.agentName
  276. ,providerName = 'RIA Financial'
  277. ,orderNo = ria.orderNo
  278. FROM riaRemitPayHistory ria WITH(NOLOCK)
  279. LEFT JOIN dbo.agentMaster am WITH(NOLOCK) ON ria.pBranch = am.agentId
  280. WHERE rowId = @rowId ORDER BY rowId DESC
  281. --## Transaction Log Details
  282. SELECT TOP 1
  283. rowId
  284. ,message
  285. ,trn.createdBy
  286. ,trn.createdDate
  287. FROM tranModifyLog trn WITH(NOLOCK) WHERE 1=2
  288. RETURN
  289. END
  290. IF (@partnerId='4909') /***** X-PRESS Money *****/
  291. BEGIN
  292. EXEC proc_errorHandler 0, 'Transaction varification successfully.', @rowId
  293. SELECT TOP 1
  294. rowId
  295. ,securityNo = dbo.FNADecryptString(xp.xpin)
  296. ,transactionDate = xp.payinDate
  297. ,senderName = xp.customerFirstName + ISNULL( ' ' + xp.customerMiddleName, '') + ISNULL( ' ' + xp.customerLastName, '')
  298. ,senderAddress = ISNULL(xp.customerAddress1,'')
  299. ,senderMobile = ISNULL(xp.customerMobile,'')
  300. ,senderTel = ISNULL(xp.customerPhone,'')
  301. ,senderIdNo = ''
  302. ,senderIdType = ''
  303. ,senderCity = customerAddressCity
  304. ,recName = xp.beneficiaryFirstName + ISNULL( ' ' + xp.beneficiaryMiddleName, '') + ISNULL( ' ' + xp.beneficiaryLastName, '')
  305. ,recAddress = xp.beneficiaryAddress1
  306. ,recMobile = ISNULL(xp.beneficiaryMobile,'')
  307. ,recTelePhone = ISNULL(xp.beneficiaryPhone,'')
  308. ,recIdType = xp.beneficiaryIDOtherType
  309. ,recIdNo = xp.beneficiaryID
  310. ,recCity = xp.beneficiaryAddressCity
  311. ,recCountry = xp.beneficiaryAddressCountry
  312. ,pAmount = xp.payoutAmount
  313. ,rCurrency = xp.payoutCcyCode
  314. ,pCurrency = xp.payoutCcyCode
  315. ,remarks = xp.messageToBeneficiary
  316. ,paymentMethod = 'Cash Payment'
  317. ,tokenId = xp.xmwsSessionID
  318. ,amt = xp.payoutAmount
  319. ,pBranch = xp.branchId
  320. ,sendingCountry = xp.sendingCountry
  321. ,sendingAgent = xp.sendingAgentName
  322. ,branchName = am.agentName
  323. ,providerName = 'XPRESS Money'
  324. ,orderNo = ''
  325. FROM xPressTranHistory xp WITH(NOLOCK)
  326. LEFT JOIN dbo.agentMaster am WITH(NOLOCK) ON xp.branchId = am.agentId
  327. WHERE rowId = @rowId ORDER BY rowId DESC
  328. --## Transaction Log Details
  329. SELECT TOP 1
  330. rowId
  331. ,message
  332. ,trn.createdBy
  333. ,trn.createdDate
  334. FROM tranModifyLog trn WITH(NOLOCK) WHERE 1=2
  335. RETURN
  336. END
  337. IF @partnerId = '4854' /***** MONEY GRAM *****/
  338. BEGIN
  339. EXEC proc_errorHandler 0, 'Transaction varification successfully.', @rowId
  340. SELECT TOP 1
  341. rowId = xp.id
  342. ,securityNo = dbo.FNADecryptString(xp.referenceNumber)
  343. ,transactionDate = xp.dateTimeSent
  344. ,senderName = xp.senderFirstName + ISNULL( ' ' + xp.senderMiddleName, '') + ISNULL( ' ' + xp.senderLastName, '')+ISNULL( ' ' + xp.senderLastName2, '')
  345. ,senderAddress = ISNULL(xp.senderAddress,'')
  346. ,senderMobile = ISNULL(xp.senderHomePhone,'')
  347. ,senderTel = ISNULL(xp.senderHomePhone,'')
  348. ,senderIdType = ''
  349. ,senderIdNo = ''
  350. ,senderCity = xp.senderCity
  351. ,senderCountry = xp.senderCountry
  352. ,recName = xp.receiverFirstName + ISNULL( ' ' + xp.receiverMiddleName, '') + ISNULL( ' ' + xp.receiverLastName, '') + ISNULL( ' ' + xp.receiverLastName2, '')
  353. ,recAddress = xp.receiverAddress
  354. ,recMobile = ''
  355. ,recTelePhone = ISNULL(xp.receiverContactNo,'')
  356. ,recIdType = xp.receiverIdType
  357. ,recIdNo = xp.receiverIdnumber
  358. ,recCity = xp.receiverCity
  359. ,recCountry = xp.receiverNativeCountry
  360. ,pAmount = floor(xp.receiveAmount)
  361. ,rCurrency = ''
  362. ,pCurrency = xp.receiveCurrency
  363. ,remarks = xp.remarks
  364. ,paymentMethod = 'Cash Payment'
  365. ,tokenId = xp.mgiTransactionSessionID
  366. ,amt = xp.receiveAmount
  367. ,pBranch = xp.branch
  368. ,sendingCountry = xp.originatingCountry
  369. ,sendingAgent = xp.agentName
  370. ,branchName = am.agentName
  371. ,providerName = 'Money Gram'
  372. ,orderNo = ''
  373. FROM mgPayHistory xp WITH(NOLOCK)
  374. LEFT JOIN dbo.agentMaster am WITH(NOLOCK) ON xp.branch = am.agentId
  375. WHERE id = @rowId ORDER BY id DESC
  376. --## Transaction Log Details
  377. SELECT TOP 1
  378. rowId
  379. ,message
  380. ,trn.createdBy
  381. ,trn.createdDate
  382. FROM tranModifyLog trn WITH(NOLOCK) WHERE 1=2
  383. RETURN
  384. END
  385. IF (@partnerId='4816') /***** Instant Cash *****/
  386. BEGIN
  387. EXEC proc_errorHandler 0, 'Transaction varification successfully.', @rowId
  388. SELECT TOP 1
  389. rowId
  390. ,securityNo = dbo.FNADecryptString(ic.ICTC_Number)
  391. ,transactionDate = CASE WHEN ISNULL(ic.Transaction_SentDate,'')<>'' AND LEN(ic.Transaction_SentDate)=8
  392. THEN SUBSTRING(ic.Transaction_SentDate,5,2)+'/'+SUBSTRING(ic.Transaction_SentDate,7,2)+'/'+SUBSTRING(ic.Transaction_SentDate,1,4)
  393. ELSE ic.Transaction_SentDate
  394. END -- 11/13/2014
  395. ,senderName = ic.Remitter_Name
  396. ,senderAddress = ISNULL(ic.Remitter_Address,'')
  397. ,senderMobile = ''
  398. ,senderTel = ''
  399. ,senderIdNo = ic.Remitter_IDDtl
  400. ,senderIdType = ic.Remitter_IDType
  401. ,senderCity = ''
  402. ,recName = ic.Beneficiary_Name
  403. ,recAddress = ic.Beneficiary_Address
  404. ,recMobile = ISNULL(ic.Beneficiary_MobileNo,'')
  405. ,recTelePhone = ISNULL(ic.Beneficiary_TelNo,'')
  406. ,recIdType = ic.rIdType
  407. ,recIdNo = ic.rIdNumber
  408. ,recCity = ic.Beneficiary_City
  409. ,recCountry = ic.Destination_Country
  410. ,pAmount = ic.Paying_Amount
  411. ,rCurrency = ic.Paying_Currency
  412. ,pCurrency = 'NPR'
  413. ,remarks = ic.remarks
  414. ,paymentMethod = 'Cash Payment'
  415. ,tokenId = ''
  416. ,amt = ic.Paying_Amount
  417. ,pBranch = ic.pBranch
  418. ,sendingCountry = ic.Originating_Country
  419. ,sendingAgent = ''
  420. ,branchName = am.agentName
  421. ,providerName = 'Instant Cash'
  422. ,orderNo = ic.Agent_OrderNumber
  423. FROM icPayHistory ic WITH(NOLOCK)
  424. LEFT JOIN dbo.agentMaster am WITH(NOLOCK) ON ic.pBranch = am.agentId
  425. WHERE rowId = @rowId ORDER BY rowId DESC
  426. --## Transaction Log Details
  427. SELECT TOP 1
  428. rowId
  429. ,message
  430. ,trn.createdBy
  431. ,trn.createdDate
  432. FROM tranModifyLog trn WITH(NOLOCK) WHERE 1=2
  433. RETURN
  434. END
  435. DECLARE
  436. @mapCodeDom VARCHAR(50)
  437. ,@tranStatus VARCHAR(50)
  438. ,@payStatus VARCHAR(50)
  439. ,@controlNoEncrypted VARCHAR(50)
  440. ,@agentType VARCHAR(50)
  441. ,@pTxnLocation VARCHAR(50)
  442. ,@pAgentLocation VARCHAR(50)
  443. ,@pAgent VARCHAR(50)
  444. ,@paymentMethod VARCHAR(50)
  445. ,@sBranchId VARCHAR(50)
  446. ,@mapCodeInt VARCHAR(50)
  447. ,@lockStatus VARCHAR(50)
  448. ,@payTokenId VARCHAR(50)
  449. IF (@partnerId='4812') /***** IME INTERNATIONAL *****/
  450. BEGIN
  451. EXEC proc_errorHandler 0, 'Transaction varification successfully.', @rowId
  452. SELECT TOP 1
  453. rowId =trn.id
  454. ,securityNo =dbo.FNADecryptString(trn.controlNo)
  455. ,transactionDate =trn.createdDateLocal
  456. ,senderName =sen.firstName + ISNULL( ' ' + sen.middleName, '') + ISNULL( ' ' + sen.lastName1, '') + ISNULL( ' ' + sen.lastName2, '')
  457. ,senderAddress =sen.address
  458. ,senderCity =sen.city
  459. ,senderMobile =sen.mobile
  460. ,senderTel =sen.homephone
  461. ,senderIdType =sen.idType
  462. ,senderIdNo =sen.idNumber
  463. ,recName =rec.firstName + ISNULL( ' ' + rec.middleName, '') + ISNULL( ' ' + rec.lastName1, '') + ISNULL( ' ' + rec.lastName2, '')
  464. ,recAddress =rec.address
  465. ,recMobile =rec.mobile
  466. ,recTelePhone =rec.homephone
  467. ,recIdType =rec.idType
  468. ,recIdNo =rec.idNumber
  469. ,recCity =rec.city
  470. ,recCountry =rec.country
  471. ,pAmount =trn.pAmt
  472. ,rCurrency =trn.collCurr
  473. ,pCurrency =trn.payoutCurr
  474. ,remarks =pMessage
  475. ,paymentMethod =trn.paymentMethod
  476. ,tokenId =trn.payTokenId
  477. ,amt =trn.pAmt
  478. ,pBranch =trn.pBranch
  479. ,sendingCountry =trn.sCountry
  480. ,sendingAgent =trn.sAgentName
  481. ,branchName =am.agentName
  482. ,providerName ='IME International'
  483. ,orderNo = ''
  484. ,agentGrp = @agentGrp
  485. ,rIdType = tpc.rIdType
  486. ,rIdNumber = tpc.rIdNumber
  487. ,rPlaceOfIssue = tpc.rPlaceOfIssue
  488. ,rRelativeName = tpc.rRelativeName
  489. ,rRelationType = tpc.rRelationType
  490. ,rContactNo = tpc.rContactNo
  491. FROM remitTran trn WITH(NOLOCK)
  492. INNER JOIN tranSenders sen WITH(NOLOCK) ON trn.id = sen.tranId
  493. INNER JOIN tranReceivers rec WITH(NOLOCK) ON trn.id = rec.tranId
  494. INNER JOIN dbo.tranPayCompliance tpc WITH(NOLOCK) ON tpc.tranId = trn.id
  495. INNER JOIN agentMaster am WITH(NOLOCK) ON am.agentId = tpc.pBranch
  496. WHERE trn.id = @rowId
  497. -- ## Transaction Log Details
  498. SELECT @controlNoEncrypted = controlNo
  499. FROM remitTran rt WITH(NOLOCK) WHERE id = @rowId
  500. SELECT
  501. rowId
  502. ,message
  503. ,trn.createdBy
  504. ,trn.createdDate
  505. FROM tranModifyLog trn WITH(NOLOCK)
  506. LEFT JOIN applicationUsers au WITH(NOLOCK) ON trn.createdBy = au.userName
  507. WHERE trn.tranId = @tranId OR trn.controlNo = @controlNoEncrypted
  508. ORDER BY trn.rowId DESC
  509. END
  510. IF (@partnerId='1002') /***** IME Nepal *****/
  511. BEGIN
  512. EXEC proc_errorHandler 0, 'Transaction varification successfully.', @rowId
  513. SELECT TOP 1
  514. rowId =trn.id
  515. ,securityNo =dbo.FNADecryptString(trn.controlNo)
  516. ,transactionDate =trn.createdDateLocal
  517. ,senderName =sen.firstName + ISNULL( ' ' + sen.middleName, '') + ISNULL( ' ' + sen.lastName1, '') + ISNULL( ' ' + sen.lastName2, '')
  518. ,senderAddress =sen.address
  519. ,senderCity =sen.city
  520. ,senderMobile =sen.mobile
  521. ,senderTel =sen.homephone
  522. ,senderIdType =sen.idType
  523. ,senderIdNo =sen.idNumber
  524. ,recName =rec.firstName + ISNULL( ' ' + rec.middleName, '') + ISNULL( ' ' + rec.lastName1, '') + ISNULL( ' ' + rec.lastName2, '')
  525. ,recAddress =rec.address
  526. ,recMobile =rec.mobile
  527. ,recTelePhone =rec.homephone
  528. ,recIdType =rec.idType
  529. ,recIdNo =rec.idNumber
  530. ,recCity =rec.city
  531. ,recCountry =rec.country
  532. ,pAmount =trn.pAmt
  533. ,rCurrency =trn.collCurr
  534. ,pCurrency =trn.payoutCurr
  535. ,remarks =pMessage
  536. ,paymentMethod =trn.paymentMethod
  537. ,tokenId =trn.payTokenId
  538. ,amt =trn.pAmt
  539. ,pBranch =trn.pBranch
  540. ,sendingCountry =trn.sCountry
  541. ,sendingAgent =trn.sAgentName
  542. ,branchName =am.agentName
  543. ,providerName ='IME Nepal'
  544. ,orderNo = ''
  545. ,agentGrp = @agentGrp
  546. ,rIdType = tpc.rIdType
  547. ,rIdNumber = tpc.rIdNumber
  548. ,rPlaceOfIssue = tpc.rPlaceOfIssue
  549. ,rRelativeName = tpc.rRelativeName
  550. ,rRelationType = tpc.rRelationType
  551. ,rContactNo = tpc.rContactNo
  552. FROM remitTran trn WITH(NOLOCK)
  553. INNER JOIN tranSenders sen WITH(NOLOCK) ON trn.id = sen.tranId
  554. INNER JOIN tranReceivers rec WITH(NOLOCK) ON trn.id = rec.tranId
  555. INNER JOIN dbo.tranPayCompliance tpc WITH(NOLOCK) ON tpc.tranId = trn.id
  556. INNER JOIN agentMaster am WITH(NOLOCK) ON am.agentId = tpc.pBranch
  557. WHERE trn.id = @rowId
  558. -- ## Transaction Log Details
  559. SELECT @controlNoEncrypted = controlNo
  560. FROM remitTran rt WITH(NOLOCK) WHERE id = @rowId
  561. SELECT
  562. rowId
  563. ,message
  564. ,trn.createdBy
  565. ,trn.createdDate
  566. FROM tranModifyLog trn WITH(NOLOCK)
  567. LEFT JOIN applicationUsers au WITH(NOLOCK) ON trn.createdBy = au.userName
  568. WHERE trn.tranId = @tranId OR trn.controlNo = @controlNoEncrypted
  569. ORDER BY trn.rowId DESC
  570. END
  571. END
  572. ELSE IF @flag='compliance'
  573. BEGIN
  574. IF @controlNo IS NULL
  575. SELECT @controlNo = dbo.FNADecryptString(controlNo) FROM tranPayCompliance WITH(NOLOCK) WHERE rowId = @id
  576. DECLARE @holdTranId BIGINT
  577. SELECT @holdTranId = holdTranId, @tranId = id FROM vwRemitTran WITH(NOLOCK) WHERE controlNo = dbo.FNAEncryptString(@controlNo)
  578. SELECT
  579. rowId
  580. ,csDetailRecId
  581. ,[S.N.] = ROW_NUMBER()OVER(ORDER BY ROWID)
  582. ,[Remarks] = ISNULL( RTRIM(LTRIM(ISNULL(dbo.FNAGetDataValue(condition),''))) + ' ' +
  583. CASE WHEN checkType = 'Sum' THEN 'Transaction Amount'
  584. WHEN checkType = 'Count' THEN 'Transaction Count' END
  585. + ' exceeds ' + CAST(PARAMETER AS VARCHAR) + ' limit within ' + CAST(period AS VARCHAR)+ ' days ' + dbo.FNAGetDataValue(criteria)
  586. ,reason)
  587. ,[Matched TRAN ID] = ISNULL(rtc.matchTranId,rtc.TranId)
  588. FROM remitTranCompliancePay rtc WITH(NOLOCK)
  589. LEFT JOIN csDetailRec cdr WITH(NOLOCK) ON rtc.csDetailTranId = cdr.csDetailRecId
  590. WHERE rtc.TranId = ISNULL(@holdTranId, @tranId)
  591. END
  592. IF @flag = 'release'
  593. BEGIN
  594. IF EXISTS(SELECT 'X' FROM tranPayCompliance WITH(NOLOCK) WHERE rowId = @id)
  595. BEGIN
  596. IF @remarks IS NULL
  597. BEGIN
  598. EXEC proc_errorHandler 1, 'Compliance remarks can not be blank.', @id
  599. RETURN;
  600. END
  601. BEGIN TRANSACTION
  602. UPDATE tranPayCompliance SET
  603. approvedRemarks = @remarks
  604. ,approvedBy = @user
  605. ,approvedDate = GETDATE()
  606. ,@tranId = tranId
  607. WHERE rowId = @id AND approvedDate IS NULL
  608. UPDATE remitTranCompliancePay SET
  609. approvedRemarks = @remarks
  610. ,approvedBy = @user
  611. ,approvedDate = GETDATE()
  612. WHERE tranId = @tranId AND approvedDate IS NULL
  613. UPDATE remitTran SET
  614. tranStatus = 'Payment'
  615. WHERE id = @tranId
  616. COMMIT TRANSACTION
  617. EXEC proc_errorHandler 0, 'Release remarks has been saved successfully.', @id
  618. END
  619. EXEC proc_errorHandler 1, 'Transaction not found.', @id
  620. END
  621. --EXEC proc_transactionView @FLAG='COMPL_DETAIL',@controlNo='1',@tranId='1'
  622. IF @flag='COMPL_DETAIL'
  623. BEGIN
  624. /*
  625. 5000 By Sender ID
  626. 5001 By Sender Name
  627. 5002 By Sender Mobile
  628. 5003 By Beneficiary ID
  629. 5004 By Beneficiary ID(System)
  630. 5005 By Beneficiary Name
  631. 5006 By Beneficiary Mobile
  632. 5007 By Beneficiary A/C Number
  633. */
  634. DECLARE @tranIds AS VARCHAR(MAX), @criteria AS INT, @totalTran AS INT, @criteriaValue AS VARCHAR(500), @reason VARCHAR(500)
  635. SELECT
  636. @tranIds = matchTranId,
  637. @tranId = TranId
  638. FROM remitTranCompliancePay with(nolock)
  639. WHERE rowId = @id --(ROWID) --id of remitTranCompliancePay
  640. SELECT @criteria = criteria FROM csDetailRec with(nolock) WHERE csDetailRecId = @csDetailRecId--id of csDetailRec
  641. SELECT @totalTran = COUNT(*) FROM dbo.Split(',', @tranIds)
  642. IF @criteria='5000'
  643. SELECT @criteriaValue = B.membershipId
  644. FROM tranSenders B with(nolock) WHERE B.tranId = @tranId
  645. IF @criteria='5001'
  646. SELECT @criteriaValue = senderName FROM remitTran with(nolock) WHERE Id = @tranId
  647. IF @criteria='5002'
  648. SELECT @criteriaValue = B.mobile
  649. FROM tranSenders B with(nolock) WHERE B.tranId = @tranId
  650. IF @criteria='5003'
  651. SELECT @criteriaValue = B.rMemId
  652. FROM tranPayCompliance B with(nolock) WHERE B.tranId = @tranId
  653. IF @criteria='5004'
  654. SELECT @criteriaValue = B.rMemId
  655. FROM tranPayCompliance B with(nolock) WHERE B.tranId = @tranId
  656. IF @criteria='5005'
  657. SELECT @criteriaValue = receiverName FROM tranPayCompliance with(nolock) WHERE tranId = @tranId
  658. IF @criteria='5006'
  659. SELECT @criteriaValue = B.rContactNo
  660. FROM tranPayCompliance B with(nolock) WHERE B.tranId = @tranId
  661. IF @criteria='5007'
  662. SELECT @criteriaValue = A.accountNo
  663. FROM remitTran A with(nolock) WHERE A.id = @tranId
  664. SELECT
  665. REMARKS = CASE WHEN @csDetailRecId = 0 THEN @reason ELSE
  666. RTRIM(LTRIM(ISNULL(dbo.FNAGetDataValue(condition),''))) + ' ' +
  667. CASE WHEN checkType = 'Sum' THEN 'Transaction Amount'
  668. WHEN checkType = 'Count' THEN 'Transaction Count' END
  669. + ' exceeds ' + CAST(parameter AS VARCHAR) + ' limit within ' + CAST(period AS VARCHAR)+ ' days ' + dbo.FNAGetDataValue(criteria)+': <font size=''2px''>'+ISNULL(@criteriaValue,'')+'</font>'
  670. END
  671. ,totTran = 'Total Count: <b>'+ CASE WHEN @csDetailRecId = 0 THEN '1' ELSE CAST(@totalTran AS VARCHAR) END +'</b>'
  672. FROM csDetailRec with(nolock)
  673. WHERE csDetailRecId= CASE WHEN @csDetailRecId=0 THEN 1 ELSE @csDetailRecId END
  674. SELECT
  675. [S.N.] = ROW_NUMBER() OVER(ORDER BY @id)
  676. ,[CONTROL NO.] = dbo.FNADecryptString(trn.controlNo)
  677. ,[TRAN AMOUNT] = dbo.ShowDecimal(trn.cAmt)
  678. ,[CURRENCY] = trn.collCurr
  679. ,[TRAN DATE] = CONVERT(VARCHAR,trn.createdDate,101)
  680. FROM VWremitTran trn with(nolock) INNER JOIN
  681. (
  682. SELECT * FROM dbo.Split(',', @tranIds)
  683. )B ON trn.id = B.value
  684. UNION ALL
  685. ---- RECORD DISPLAY FROM CANCEL TRANSACTION TABLE
  686. SELECT
  687. [S.N.] = ROW_NUMBER() OVER(ORDER BY @controlNo)
  688. ,[CONTROL NO.] = dbo.FNADecryptString(trn.controlNo)
  689. ,[TRAN AMOUNT] = dbo.ShowDecimal(trn.cAmt)
  690. ,[CURRENCY] = trn.collCurr
  691. ,[TRAN DATE] = CONVERT(VARCHAR,trn.createdDate,101)
  692. FROM cancelTranHistory trn with(nolock) INNER JOIN
  693. (
  694. SELECT * FROM dbo.Split(',', @tranIds)
  695. )B ON trn.tranId = B.value
  696. END
  697. END TRY
  698. BEGIN CATCH
  699. IF @@TRANCOUNT > 0 ROLLBACK TRAN
  700. END CATCH
  701. GO