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.

674 lines
18 KiB

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