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.

670 lines
37 KiB

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