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.

655 lines
34 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_DYNAMIC_TABLE] Script Date: 10/9/2023 10:15:54 AM ******/
  4. SET ANSI_NULLS ON
  5. GO
  6. SET QUOTED_IDENTIFIER ON
  7. GO
  8. ALTER PROC [dbo].[PROC_DYNAMIC_TABLE] (
  9. @Flag VARCHAR(20)
  10. ,@UserEmail VARCHAR(150) = NULL
  11. ,@User VARCHAR(150) = NULL
  12. ,@ShowAll VARCHAR(5) = NULL
  13. ,@selectedValue1 VARCHAR(20) = NULL
  14. ,@CountryId INT = NULL
  15. ,@PaymentMethod INT = NULL
  16. ,@Password VARCHAR(40) = NULL
  17. ,@ConfirmPassword VARCHAR(40) = NULL
  18. ,@ipAddress VARCHAR(20) = NULL
  19. ,@id BIGINT = NULL
  20. ,@SchemeId VARCHAR(30) = NULL
  21. )
  22. AS
  23. ;
  24. SET NOCOUNT ON;
  25. SET XACT_ABORT ON;
  26. ---------------------------------------------------------------------------------------------------
  27. -- #19577 added new flags @flag = 'cust-detail' & 'tran-detail' for txn and receiver detail modal
  28. ---------------------------------------------------------------------------------------------------
  29. BEGIN TRY
  30. DECLARE @ErrorMsg VARCHAR(MAX)
  31. DECLARE @agentid INT = 394395
  32. IF @Flag = 'CustomerTxn'
  33. BEGIN
  34. SELECT TOP 3 Id = rt.id
  35. ,Amount = pAmt
  36. ,STATUS = CASE
  37. WHEN rt.tranStatus = 'Cancel'
  38. THEN 'CANCELLED'
  39. WHEN rt.tranStatus = 'Payment'
  40. AND rt.payStatus = 'Unpaid'
  41. AND rt.paymentMethod = 'Bank Deposit'
  42. THEN 'AWAITING PAYMENT'
  43. WHEN rt.tranStatus = 'Payment'
  44. AND rt.payStatus = 'Post'
  45. AND rt.paymentMethod = 'Cash Payment'
  46. THEN 'READY TO COLLECT'
  47. WHEN rt.tranStatus = 'Payment'
  48. AND rt.payStatus = 'Post'
  49. AND rt.paymentMethod = 'Bank Deposit'
  50. THEN 'PROCESSING'
  51. ELSE UPPER(rt.tranStatus)
  52. END
  53. ,TransactionDay = DATEPART(DAY, createdDate)
  54. ,TransactionMonth = DATENAME(MONTH, createdDate)
  55. ,PaymentMethod
  56. ,PBankName
  57. ,PCurrency = payoutCurr
  58. ,errorCode = 0
  59. ,msg = 'Success'
  60. FROM dbo.remitTran(NOLOCK) rt
  61. INNER JOIN dbo.tranSenders s(NOLOCK) ON s.tranid = rt.id
  62. WHERE s.customerId = @id
  63. UNION ALL
  64. SELECT TOP 3 Id = rtt.id
  65. ,Amount = pAmt
  66. ,STATUS = CASE
  67. WHEN payStatus = 'Paid'
  68. THEN 'Paid'
  69. WHEN tranStatus = 'Cancel'
  70. OR payStatus = 'Cancel'
  71. THEN 'Cancel'
  72. ELSE 'PROCESSING'
  73. END
  74. ,TransactionDay = DATEPART(DAY, createdDate)
  75. ,TransactionMonth = DATENAME(MONTH, createdDate)
  76. ,PaymentMethod
  77. ,PBankName
  78. ,PCurrency = payoutCurr
  79. ,errorCode = 0
  80. ,msg = 'Success'
  81. FROM dbo.remitTranTemp(NOLOCK) rtt
  82. INNER JOIN dbo.tranSendersTemp ts(NOLOCK) ON ts.tranid = rtt.id
  83. WHERE ts.customerId = @id
  84. END
  85. ELSE IF @Flag = 'ForceChange'
  86. BEGIN
  87. DECLARE @OldPassword VARCHAR(40) = NULL
  88. SELECT @OldPassword = DBO.DECRYPTDB(customerPassword)
  89. FROM CUSTOMERMASTER(NOLOCK)
  90. WHERE EMAIL = @UserEmail
  91. AND isForcedPwdChange = 1
  92. IF ISNULL(@OldPassword, '') = ''
  93. BEGIN
  94. SELECT errorCode = 1
  95. ,msg = 'Invalid customer!'
  96. ,id = NULL
  97. RETURN;
  98. END
  99. IF @OldPassword = @Password
  100. BEGIN
  101. SELECT errorCode = 1
  102. ,msg = 'Old password and new password can not be same!'
  103. ,id = NULL
  104. RETURN;
  105. END
  106. UPDATE CUSTOMERMASTER
  107. SET isForcedPwdChange = 0
  108. ,customerPassword = dbo.fnaencryptstring(@Password)
  109. WHERE EMAIL = @UserEmail
  110. SELECT errorCode = 0
  111. ,msg = 'Password changed successfully!'
  112. ,id = NULL
  113. RETURN;
  114. END
  115. ELSE IF @Flag = 'PayoutMethod'
  116. BEGIN
  117. DECLARE @PayoutCurrency VARCHAR(5)
  118. ,@tpExRate MONEY
  119. SELECT @tpExRate = detailDesc
  120. FROM staticDataValue(NOLOCK)
  121. WHERE typeId = '8109'
  122. AND detailTitle = @SchemeId
  123. SELECT @PayoutCurrency = CM.currencyCode
  124. FROM countryCurrency CC(NOLOCK)
  125. INNER JOIN currencyMaster CM(NOLOCK) ON CM.currencyId = CC.currencyId
  126. WHERE CC.countryId = @CountryId
  127. AND ISNULL(CC.isActive, 'Y') = 'Y'
  128. AND CC.isDefault = 'Y'
  129. IF @PaymentMethod IS NULL
  130. BEGIN
  131. SELECT agentId
  132. ,isRealTime
  133. ,exRateCalByPartner
  134. ,CM.COUNTRYCODE
  135. ,CM.CountryName
  136. ,AgentId
  137. ,PayoutCurrency = @PayoutCurrency
  138. ,tpExRate = @tpExRate
  139. FROM TblPartnerwiseCountry P(NOLOCK)
  140. INNER JOIN COUNTRYMASTER CM(NOLOCK) ON CM.COUNTRYID = P.COUNTRYID
  141. WHERE P.countryId = @CountryId
  142. AND (
  143. PaymentMethod IS NULL
  144. OR PaymentMethod IS NOT NULL
  145. )
  146. AND P.IsActive = 1
  147. END
  148. ELSE
  149. BEGIN
  150. SELECT agentId
  151. ,isRealTime
  152. ,exRateCalByPartner
  153. ,CM.COUNTRYCODE
  154. ,CM.CountryName
  155. ,AgentId
  156. ,PayoutCurrency = @PayoutCurrency
  157. ,tpExRate = @tpExRate
  158. FROM TblPartnerwiseCountry P(NOLOCK)
  159. INNER JOIN COUNTRYMASTER CM(NOLOCK) ON CM.COUNTRYID = P.COUNTRYID
  160. WHERE P.countryId = @CountryId
  161. AND ISNULL(PaymentMethod, @PaymentMethod) = @PaymentMethod
  162. AND P.IsActive = 1
  163. END
  164. END
  165. ELSE IF @Flag = 'CustomerReceiver'
  166. BEGIN
  167. SELECT TOP 3 Id = receiverId
  168. ,Name = FULLNAME
  169. ,Country = country
  170. ,Mobile
  171. ,TransactionType = SM.typeTitle
  172. ,errorCode = 0
  173. ,msg = 'Success'
  174. FROM receiverInformation RI(NOLOCK)
  175. INNER JOIN serviceTypeMaster SM(NOLOCK) ON SM.serviceTypeId = RI.paymentMode
  176. WHERE Ri.customerId = @id order by RI.createdDate desc
  177. END
  178. ELSE IF @Flag = 'receiverList'
  179. BEGIN
  180. SELECT Id = receiverId
  181. ,TEXT = FULLNAME
  182. ,errorCode = 0
  183. ,msg = 'Success'
  184. FROM receiverInformation RI(NOLOCK)
  185. INNER JOIN countryMaster CM(NOLOCK) ON CM.countryName = RI.country
  186. WHERE CM.countryId = @selectedValue1
  187. END
  188. ELSE IF @Flag = 'purpose'
  189. BEGIN
  190. SELECT Id = valueId
  191. ,TEXT = detailTitle
  192. ,errorCode = 0
  193. ,msg = 'Success'
  194. FROM staticdatavalue(NOLOCK)
  195. WHERE typeid = 3800
  196. AND ISNULL(ISActive, 'Y') = 'Y'
  197. AND ISNULL(IS_DELETE, 'N') = 'N'
  198. ORDER BY detailTitle ASC
  199. END
  200. ELSE IF @Flag = 'howToPay'
  201. BEGIN
  202. SELECT Id = 'ONLINE'
  203. ,TEXT = 'Online Banking(Best Rate)'
  204. ,extra = 0
  205. ,errorCode = 0
  206. ,msg = 'Success'
  207. UNION ALL
  208. SELECT Id = 'EBANKING'
  209. ,TEXT = 'E-Banking/ (Good rate)'
  210. ,extra = 0
  211. ,errorCode = 0
  212. ,msg = 'Success'
  213. UNION ALL
  214. SELECT Id = 'DEBIT_CARD'
  215. ,TEXT = 'DEBIT CARD'
  216. ,extra = 0.15
  217. ,errorCode = 0
  218. ,msg = 'Success'
  219. END
  220. ELSE IF @Flag = 'pCountry'
  221. BEGIN
  222. SET @countryId = 233
  223. SELECT Id = countryId
  224. ,TEXT = UPPER(countryName)
  225. ,errorCode = 0
  226. ,msg = 'Success'
  227. FROM countryMaster CM WITH (NOLOCK)
  228. INNER JOIN (
  229. SELECT receivingCountry
  230. ,min(maxLimitAmt) maxLimitAmt
  231. FROM (
  232. SELECT receivingCountry
  233. ,max(maxLimitAmt) maxLimitAmt
  234. FROM sendTranLimit SL WITH (NOLOCK)
  235. WHERE --countryId = @countryId
  236. --AND
  237. ISNULL(isActive, 'N') = 'Y'
  238. AND ISNULL(isDeleted, 'N') = 'N'
  239. AND ISNULL(agentId, ISNULL(@agentid, 0)) = ISNULL(@agentid, 0)
  240. GROUP BY receivingCountry
  241. UNION ALL
  242. SELECT receivingCountry
  243. ,max(maxLimitAmt) maxLimitAmt
  244. FROM sendTranLimit SL WITH (NOLOCK)
  245. WHERE agentId = @agentid
  246. AND ISNULL(isActive, 'N') = 'Y'
  247. AND ISNULL(isDeleted, 'N') = 'N'
  248. GROUP BY receivingCountry
  249. ) x
  250. GROUP BY receivingCountry
  251. ) Y ON Y.receivingCountry = CM.countryId
  252. WHERE ISNULL(isOperativeCountry, '') = 'Y'
  253. AND Y.maxLimitAmt > 0
  254. ORDER BY countryName ASC
  255. END
  256. ELSE IF @Flag = 'pMode'
  257. BEGIN
  258. SET @countryId = 233
  259. SELECT Id = serviceTypeId
  260. ,TEXT = UPPER(typeTitle)
  261. ,errorCode = 0
  262. ,msg = 'Success'
  263. FROM serviceTypeMaster stm WITH (NOLOCK)
  264. INNER JOIN (
  265. SELECT receivingMode
  266. ,maxLimitAmt
  267. FROM countryReceivingMode crm WITH (NOLOCK)
  268. INNER JOIN sendTranLimit SL WITH (NOLOCK) ON crm.countryId = SL.receivingCountry
  269. WHERE SL.countryId = @countryId
  270. AND SL.receivingCountry = @selectedValue1
  271. AND SL.agentId IS NULL
  272. AND SL.tranType IS NULL
  273. AND receivingAgent IS NULL
  274. UNION ALL
  275. SELECT receivingMode
  276. ,maxLimitAmt
  277. FROM countryReceivingMode crm WITH (NOLOCK)
  278. INNER JOIN sendTranLimit SL WITH (NOLOCK) ON crm.countryId = SL.receivingCountry
  279. AND SL.receivingCountry = @selectedValue1
  280. AND SL.countryId = @countryId
  281. WHERE agentId = @agentId
  282. AND SL.tranType IS NULL
  283. AND receivingAgent IS NULL
  284. AND ISNULL(isActive, 'N') = 'Y'
  285. AND ISNULL(isDeleted, 'N') = 'N'
  286. UNION ALL
  287. SELECT tranType
  288. ,MAX(maxLimitAmt) maxLimitAmt
  289. FROM sendTranLimit SL WITH (NOLOCK)
  290. WHERE countryId = @countryId
  291. AND SL.receivingCountry = @selectedValue1
  292. AND ISNULL(isActive, 'N') = 'Y'
  293. AND ISNULL(isDeleted, 'N') = 'N'
  294. AND SL.agentId IS NULL
  295. AND SL.tranType IS NOT NULL
  296. AND SL.receivingAgent IS NULL
  297. GROUP BY tranType
  298. UNION ALL
  299. SELECT tranType
  300. ,MAX(maxLimitAmt) maxLimitAmt
  301. FROM sendTranLimit SL WITH (NOLOCK)
  302. WHERE countryId = @countryId
  303. AND SL.receivingCountry = @selectedValue1
  304. AND SL.agentId = @agentid
  305. AND ISNULL(isActive, 'N') = 'Y'
  306. AND ISNULL(isDeleted, 'N') = 'N'
  307. AND receivingAgent IS NULL
  308. AND SL.tranType IS NOT NULL
  309. AND SL.receivingAgent IS NULL
  310. GROUP BY tranType
  311. ) X ON X.receivingMode = stm.serviceTypeId
  312. WHERE ISNULL(STM.isActive, 'N') = 'Y'
  313. AND ISNULL(STM.isDeleted, 'N') = 'N'
  314. AND (STM.serviceTypeId NOT IN (5))
  315. --AND (STM.serviceTypeId NOT IN (3,5))
  316. GROUP BY serviceTypeId
  317. ,typetitle
  318. HAVING MIN(X.maxLimitAmt) > 0
  319. ORDER BY serviceTypeId ASC
  320. END
  321. ELSE IF @Flag = 'Txn-Detail'
  322. BEGIN
  323. SELECT ControlNo = dbo.decryptdb(rt.controlNo)
  324. ,rt.receivername
  325. ,tr.firstName AS recFName
  326. ,tr.middleName AS recMidName
  327. ,tr.lastName1 AS recLName
  328. ,rt.camt
  329. ,rt.id
  330. ,rt.collCurr
  331. ,tr.address raddress
  332. ,rt.createdDate
  333. ,rt.paymentMethod
  334. ,collMode = rt.depositType
  335. ,rt.pbankname
  336. ,rt.pbankBranchName
  337. ,rt.accountNo
  338. ,rt.purposeofremit
  339. ,STATUS = CASE
  340. WHEN payStatus = 'Paid'
  341. THEN 'Paid'
  342. WHEN tranStatus = 'Cancel'
  343. OR payStatus = 'Cancel'
  344. THEN 'Cancel'
  345. ELSE 'Processing'
  346. END
  347. ,rt.pamt
  348. ,rt.payoutCurr
  349. ,rt.customerRate
  350. ,PromotionPremiumRate = 0
  351. ,rt.tamt
  352. ,rt.collCurr
  353. ,rt.servicecharge
  354. ,PromotionDiscount = 0
  355. ,rt.camt
  356. ,rt.pCountry
  357. ,ts.zipcode
  358. ,ts.firstname + ' ' + ts.middlename firstname
  359. ,ts.lastname1
  360. ,ts.address
  361. ,ts.city
  362. ,ts.mobile
  363. ,SenderName = ISNULL(ts.fullname, ts.firstname + ' ' + ts.lastname1)
  364. FROM remitTranTemp rt(NOLOCK)
  365. INNER JOIN tranReceiversTemp tr(NOLOCK) ON tr.tranid = rt.id
  366. INNER JOIN transendersTemp ts(NOLOCK) ON ts.tranid = rt.id
  367. WHERE rt.id = @id
  368. UNION ALL
  369. SELECT ControlNo = dbo.decryptdb(rt.controlNo)
  370. ,rt.receivername
  371. ,tr.firstName AS recFName
  372. ,tr.middleName AS recMidName
  373. ,tr.lastName1 AS recLName
  374. ,rt.camt
  375. ,rt.id
  376. ,rt.collCurr
  377. ,tr.address raddress
  378. ,rt.createdDate
  379. ,rt.paymentMethod
  380. ,collMode = rt.depositType
  381. ,rt.pbankname
  382. ,rt.pbankBranchName
  383. ,rt.accountNo
  384. ,rt.purposeofremit
  385. ,STATUS = CASE
  386. WHEN payStatus = 'Paid'
  387. THEN 'Paid'
  388. WHEN tranStatus = 'Cancel'
  389. OR payStatus = 'Cancel'
  390. THEN 'Cancel'
  391. ELSE 'Processing'
  392. END
  393. ,rt.pamt
  394. ,rt.payoutCurr
  395. ,rt.customerRate
  396. ,PromotionPremiumRate = 0
  397. ,rt.tamt
  398. ,rt.collCurr
  399. ,rt.servicecharge
  400. ,PromotionDiscount = 0
  401. ,rt.camt
  402. ,rt.pCountry
  403. ,ts.zipcode
  404. ,ts.firstname + ' ' + ts.middlename firstname
  405. ,ts.lastname1
  406. ,ts.address
  407. ,ts.city
  408. ,ts.mobile
  409. ,SenderName = ISNULL(ts.fullname, ts.firstname + ' ' + ts.lastname1)
  410. FROM remitTran rt(NOLOCK)
  411. INNER JOIN tranReceivers tr(NOLOCK) ON tr.tranid = rt.id
  412. INNER JOIN transenders ts(NOLOCK) ON ts.tranid = rt.id
  413. WHERE rt.id = @id
  414. END
  415. ELSE IF @Flag = 'allCountrylist'
  416. BEGIN
  417. SELECT Id = @CountryId
  418. ,TEXT = UPPER(countryName)
  419. FROM dbo.countryMaster(NOLOCK)
  420. ORDER BY ISNULL(isOperativeCountry, 'N') DESC
  421. ,countryName
  422. END
  423. ELSE IF @flag = 'tran-detail-all'
  424. BEGIN
  425. SELECT cAmt
  426. ,serviceCharge
  427. ,(cAmt - serviceCharge + ISNULL(rewardpoints, 0)) AS tAmt
  428. ,Amount = pAmt
  429. ,pBankName
  430. ,pCountry
  431. ,paymentMethod
  432. ,Id = rt.id
  433. ,SenderName = ISNULL(s.fullname, s.firstname + ' ' + s.lastname1)
  434. ,FORMAT(createdDate, 'dd MMMM, yyyy') AS tranDate
  435. ,STATUS = CASE
  436. WHEN rt.tranStatus = 'Cancel'
  437. THEN 'CANCELLED'
  438. WHEN rt.tranStatus = 'Payment'
  439. AND rt.payStatus = 'Unpaid'
  440. AND rt.paymentMethod = 'Bank Deposit'
  441. THEN 'AWAITING PAYMENT'
  442. WHEN rt.tranStatus = 'Payment'
  443. AND rt.payStatus = 'Post'
  444. AND rt.paymentMethod = 'Cash Payment'
  445. THEN 'READY TO COLLECT'
  446. WHEN rt.tranStatus = 'Payment'
  447. AND rt.payStatus = 'Post'
  448. AND rt.paymentMethod = 'Bank Deposit'
  449. THEN 'PROCESSING'
  450. ELSE UPPER(rt.tranStatus)
  451. END
  452. ,errorCode = 0
  453. ,msg = 'Success'
  454. FROM dbo.remitTran(NOLOCK) rt
  455. INNER JOIN dbo.tranSenders s(NOLOCK) ON s.tranid = rt.id
  456. WHERE rt.id = @id
  457. UNION ALL
  458. SELECT cAmt
  459. ,serviceCharge
  460. ,(cAmt - serviceCharge + ISNULL(rewardpoints, 0)) AS tAmt
  461. ,Amount = pAmt
  462. ,pBankName
  463. ,pCountry
  464. ,PaymentMethod
  465. ,rtt.id
  466. ,SenderName = ISNULL(ts.fullname, ts.firstname + ' ' + ts.lastname1)
  467. ,FORMAT(createdDate, 'dd MMMM, yyyy') AS tranDate
  468. ,STATUS = CASE
  469. WHEN payStatus = 'Paid'
  470. THEN 'Paid'
  471. WHEN tranStatus = 'Cancel'
  472. OR payStatus = 'Cancel'
  473. THEN 'Cancel'
  474. ELSE 'PROCESSING'
  475. END
  476. ,errorCode = 0
  477. ,msg = 'Success'
  478. FROM dbo.remitTranTemp(NOLOCK) rtt
  479. INNER JOIN dbo.tranSendersTemp ts(NOLOCK) ON ts.tranid = rtt.id
  480. WHERE rtt.id = @id
  481. END
  482. ELSE IF @flag = 'cust-detail'
  483. BEGIN
  484. SELECT rt.tranStatus AS tranStatus
  485. ,rt.pAmt AS nprAmt
  486. ,CONCAT (
  487. RI.firstName
  488. ,' '
  489. ,RI.middleName
  490. ,' '
  491. ,RI.lastName1
  492. ) AS FullName
  493. ,rt.id AS tranId
  494. ,rt.createdDate AS tranDate
  495. ,tr.address AS address
  496. ,ISNULL(tr.mobile, RI.mobile) AS mobile
  497. ,rt.cAmt AS collAmt
  498. ,rt.serviceCharge AS serviceCharge
  499. ,rt.rewardPoints AS customerPremium
  500. ,rt.tAmt AS sentAmt
  501. ,rt.customerRate AS exRate
  502. ,rt.pAmt AS payoutAmt
  503. ,rt.pAgentName AS pAgent
  504. ,errorCode = 0
  505. ,msg = 'Success'
  506. FROM receiverInformation RI(NOLOCK)
  507. LEFT JOIN tranReceivers tr(NOLOCK) ON tr.id = RI.receiverId
  508. LEFT JOIN remitTran rt(NOLOCK) ON rt.id = tr.tranId
  509. WHERE RI.receiverId = @id
  510. END
  511. ELSE IF @Flag = 'CustomerTxn-all'
  512. BEGIN
  513. SELECT Id = rt.id
  514. ,recName = rt.receiverName
  515. ,recAccNum = rt.accountNo
  516. ,Amount = pAmt
  517. --,STATUS = CASE
  518. -- WHEN rt.tranStatus = 'Cancel'
  519. -- THEN 'CANCELLED'
  520. -- WHEN rt.tranStatus = 'Payment'
  521. -- AND rt.payStatus = 'Unpaid'
  522. -- AND rt.paymentMethod = 'Bank Deposit'
  523. -- THEN 'AWAITING PAYMENT'
  524. -- WHEN rt.tranStatus = 'Payment'
  525. -- AND rt.payStatus = 'Post'
  526. -- AND rt.paymentMethod = 'Cash Payment'
  527. -- THEN 'READY TO COLLECT'
  528. -- WHEN rt.tranStatus = 'Payment'
  529. -- AND rt.payStatus = 'Post'
  530. -- AND rt.paymentMethod = 'Bank Deposit'
  531. -- THEN 'PROCESSING'
  532. -- ELSE UPPER(rt.tranStatus)
  533. -- END
  534. --,TransactionDay = DATEPART(DAY, createdDate)
  535. --,TransactionMonth = DATENAME(MONTH, createdDate)
  536. ,PaymentMethod
  537. ,rt.pCountry
  538. --,PBankName
  539. --,PCurrency = payoutCurr
  540. ,errorCode = 0
  541. ,msg = 'Success'
  542. FROM dbo.remitTran(NOLOCK) rt
  543. INNER JOIN dbo.tranSenders s(NOLOCK) ON s.tranid = rt.id
  544. WHERE s.customerId = @id
  545. UNION ALL
  546. SELECT Id = rtt.id
  547. ,recName = rtt.receiverName
  548. ,recAccNum = rtt.accountNo
  549. ,Amount = pAmt
  550. --,STATUS = CASE
  551. -- WHEN payStatus = 'Paid'
  552. -- THEN 'Paid'
  553. -- WHEN tranStatus = 'Cancel'
  554. -- OR payStatus = 'Cancel'
  555. -- THEN 'Cancel'
  556. -- ELSE 'PROCESSING'
  557. -- END
  558. --,TransactionDay = DATEPART(DAY, createdDate)
  559. --,TransactionMonth = DATENAME(MONTH, createdDate)
  560. ,PaymentMethod
  561. ,rtt.pCountry
  562. --,PBankName
  563. --,PCurrency = payoutCurr
  564. ,errorCode = 0
  565. ,msg = 'Success'
  566. FROM dbo.remitTranTemp(NOLOCK) rtt
  567. INNER JOIN dbo.tranSendersTemp ts(NOLOCK) ON ts.tranid = rtt.id
  568. WHERE ts.customerId = @id
  569. END
  570. ELSE IF @Flag = 'CustomerReceiver-all'
  571. BEGIN
  572. SELECT Id = receiverId
  573. ,Name = FULLNAME
  574. ,Country = country
  575. ,Mobile
  576. ,TransactionType = SM.typeTitle
  577. ,errorCode = 0
  578. ,msg = 'Success'
  579. FROM receiverInformation RI(NOLOCK)
  580. INNER JOIN serviceTypeMaster SM(NOLOCK) ON SM.serviceTypeId = RI.paymentMode
  581. WHERE Ri.customerId = @id
  582. END
  583. ELSE IF @Flag = 'edit-customer'
  584. BEGIN
  585. print 'rr'
  586. SELECT Id = receiverId
  587. ,FirstName = firstName
  588. ,middleName = middleName
  589. ,LastName1 = lastName1
  590. ,relationship = ISNULL(relationOther,'')
  591. ,Country = country
  592. ,address = ISNULL(address, '')
  593. ,city = ISNULL(city,'')
  594. ,zipCode = ISNULL(zipCode,'')
  595. ,mobile = ISNULL(mobile,'')
  596. ,email = ISNULL(email,'')
  597. ,paymentMode = ISNULL(STM.typeTitle,'')
  598. ,idType = ISNULL(sdv.detailTitle,'')
  599. ,idNumber = ISNULL(idNumber,'')
  600. ,bank = ISNULL(bank, '')
  601. ,bankName = ISNULL(bankBranchName,'')
  602. ,accountNum = ISNULL(receiverAccountNo,'')
  603. ,errorCode = 0
  604. ,msg = 'Success'
  605. FROM receiverInformation RI(NOLOCK)
  606. LEFT JOIN serviceTypeMaster STM ON RI.paymentMode = stm.serviceTypeId
  607. LEFT JOIN staticDataValue sdv ON RI.idType = sdv.valueId
  608. WHERE receiverId = @id
  609. END
  610. END TRY
  611. BEGIN CATCH
  612. SET @ErrorMsg = 'Internal Server Error: ' + ERROR_MESSAGE()
  613. SELECT errorCode = 1
  614. ,msg = @ErrorMsg
  615. ,id = NULL
  616. END CATCH