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.

666 lines
35 KiB

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