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.

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