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.

730 lines
40 KiB

  1. USE [FastMoneyPro_Remit]
  2. GO
  3. /****** Object: StoredProcedure [dbo].[PROC_DYNAMIC_TABLE] Script Date: 1/29/2024 4:21:49 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. --EXEC PROC_DYNAMIC_TABLE @flag='CustomerTxn',@id='2'
  27. ---------------------------------------------------------------------------------------------------
  28. -- #19577 added new flags @flag = 'cust-detail' & 'tran-detail' for txn and receiver detail modal
  29. -- #20203 added new flag = 'update-customer' to update receiver
  30. ---------------------------------------------------------------------------------------------------
  31. BEGIN TRY
  32. DECLARE @ErrorMsg VARCHAR(MAX)
  33. DECLARE @agentid INT = 394395
  34. IF @Flag = 'CustomerTxn'
  35. BEGIN
  36. select * from (
  37. SELECT top 3 Id = rt.id
  38. ,tAmount = tAmt
  39. ,Amount = pAmt
  40. ,STATUS = CASE WHEN rt.tranStatus='Reject' then 'DECLINED'
  41. WHEN rt.tranStatus='Cancel' then 'CANCELLED'
  42. WHEN rt.paystatus='POST' then 'PROCESSING'
  43. WHEN depositType ='ONLINE' AND rt.verifiedDate IS NULL THEN 'PENDING'
  44. WHEN depositType ='DEBIT_CARD' AND rt.verifiedDate IS NOT NULL THEN 'PROCESSING'
  45. else UPPER(payStatus) end
  46. ,TransactionDay = DATEPART(DAY, createdDate)
  47. ,TransactionMonth = FORMAT(createdDate, 'MMM', 'en-US')
  48. ,PaymentMethod
  49. ,PBankName
  50. ,dbo.decryptDb( controlNo) controlNo
  51. ,receiverName
  52. ,collCurr
  53. ,PCurrency = payoutCurr
  54. ,errorCode = 0
  55. ,msg = 'Success'
  56. ,createdDate
  57. FROM dbo.remitTran(NOLOCK) rt
  58. INNER JOIN dbo.tranSenders s(NOLOCK) ON s.tranid = rt.id
  59. WHERE s.customerId = @id
  60. ORDER BY createdDate DESC
  61. UNION ALL
  62. SELECT top 3 Id = rtt.id
  63. ,tAmount = tAmt
  64. ,Amount = pAmt
  65. ,STATUS = CASE WHEN rtt.tranStatus='Reject' then 'DECLINED'
  66. WHEN rtt.tranStatus='Cancel' then 'CANCELLED'
  67. WHEN depositType ='ONLINE' AND rtt.verifiedDate IS NULL THEN 'PENDING'
  68. WHEN depositType ='DEBIT_CARD' AND rtt.verifiedDate IS NOT NULL THEN 'PROCESSING'
  69. else UPPER('PENDING') end
  70. ,TransactionDay = DATEPART(DAY, createdDate)
  71. ,TransactionMonth = FORMAT(createdDate, 'MMM', 'en-US')
  72. ,PaymentMethod
  73. ,PBankName
  74. ,dbo.decryptDb( controlNo) controlNo
  75. ,receiverName
  76. ,collCurr
  77. ,PCurrency = payoutCurr
  78. ,errorCode = 0
  79. ,msg = 'Success'
  80. ,createdDate
  81. FROM dbo.remitTranTemp(NOLOCK) rtt
  82. INNER JOIN dbo.tranSendersTemp ts(NOLOCK) ON ts.tranid = rtt.id
  83. WHERE ts.customerId = @id
  84. ORDER BY createdDate DESC
  85. )da
  86. ORDER BY da.createdDate desc
  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 = ISNULL(margin, 0)
  123. FROM countryWiseExchangeRate
  124. WHERE countryId = @CountryId AND depositType = @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 = country
  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 + ' ' + ISNULL(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. ,ts.email
  366. FROM remitTranTemp rt(NOLOCK)
  367. INNER JOIN tranReceiversTemp tr(NOLOCK) ON tr.tranid = rt.id
  368. INNER JOIN transendersTemp ts(NOLOCK) ON ts.tranid = rt.id
  369. WHERE rt.id = @id
  370. UNION ALL
  371. SELECT ControlNo = dbo.decryptdb(rt.controlNo)
  372. ,rt.receivername
  373. ,tr.firstName AS recFName
  374. ,tr.middleName AS recMidName
  375. ,tr.lastName1 AS recLName
  376. ,rt.camt
  377. ,rt.id
  378. ,rt.collCurr
  379. ,tr.address raddress
  380. ,rt.createdDate
  381. ,rt.paymentMethod
  382. ,collMode = rt.depositType
  383. ,rt.pbankname
  384. ,rt.pbankBranchName
  385. ,rt.accountNo
  386. ,rt.purposeofremit
  387. ,STATUS = CASE WHEN rt.tranStatus='Reject' then 'DECLINED'
  388. WHEN rt.tranStatus='Cancel' then 'CANCELLED'
  389. WHEN rt.tranStatus='paid' then 'PAID'
  390. WHEN depositType = 'ONLINE' AND rt.verifiedDate IS NULL THEN 'PENDING'
  391. WHEN depositType in('ONLINE','DEBIT_CARD') AND rt.verifiedDate IS NOT NULL THEN 'PROCESSING'
  392. else UPPER(payStatus) 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 + ' ' + ISNULL(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. ,rt.tranType
  411. ,ts.email
  412. FROM remitTran rt(NOLOCK)
  413. INNER JOIN tranReceivers tr(NOLOCK) ON tr.tranid = rt.id
  414. INNER JOIN transenders ts(NOLOCK) ON ts.tranid = rt.id
  415. WHERE rt.id = @id
  416. END
  417. ELSE IF @Flag = 'allCountrylist'
  418. BEGIN
  419. SELECT Id = @CountryId
  420. ,TEXT = UPPER(countryName)
  421. FROM dbo.countryMaster(NOLOCK)
  422. ORDER BY ISNULL(isOperativeCountry, 'N') DESC
  423. ,countryName
  424. END
  425. ELSE IF @flag = 'tran-detail-all'
  426. BEGIN
  427. SELECT cAmt
  428. ,serviceCharge
  429. ,(cAmt - serviceCharge + ISNULL(rewardpoints, 0)) AS tAmt
  430. ,Amount = pAmt
  431. ,pBankName
  432. ,rt.pbankBranchName
  433. ,rt.accountNo
  434. ,PromotionPremiumRate = 0
  435. ,PromotionDiscount = 0
  436. ,pCountry
  437. ,paymentMethod
  438. ,Id = rt.id
  439. ,dbo.decryptDb( controlNo) controlNo
  440. ,SenderName = ISNULL(s.fullname, s.firstname + ' ' + s.lastname1)
  441. ,ReceiverName = rt.receiverName
  442. ,FORMAT(createdDate, 'dd MMMM, yyyy') AS tranDate
  443. ,rt.customerRate
  444. ,[Status] = CASE
  445. WHEN rt.tranStatus = 'Cancel'
  446. THEN 'CANCELLED'
  447. WHEN rt.tranStatus = 'Payment'
  448. AND rt.payStatus = 'Unpaid'
  449. AND rt.paymentMethod = 'Bank Deposit'
  450. THEN 'AWAITING PAYMENT'
  451. WHEN rt.tranStatus = 'Payment'
  452. AND rt.payStatus = 'Post'
  453. AND rt.paymentMethod = 'Cash Payment'
  454. THEN 'READY TO COLLECT'
  455. WHEN rt.tranStatus = 'Payment'
  456. AND rt.payStatus = 'Post'
  457. AND rt.paymentMethod = 'Bank Deposit'
  458. THEN 'PROCESSING'
  459. ELSE UPPER(rt.tranStatus)
  460. END
  461. ,errorCode = 0
  462. ,msg = 'Success'
  463. FROM dbo.remitTran(NOLOCK) rt
  464. INNER JOIN dbo.tranSenders s(NOLOCK) ON s.tranid = rt.id
  465. WHERE rt.id = @id
  466. UNION ALL
  467. SELECT cAmt
  468. ,serviceCharge
  469. ,(cAmt - serviceCharge + ISNULL(rewardpoints, 0)) AS tAmt
  470. ,Amount = pAmt
  471. ,pBankName
  472. ,rtt.pbankBranchName
  473. ,rtt.accountNo
  474. ,PromotionPremiumRate = 0
  475. ,PromotionDiscount = 0
  476. ,pCountry
  477. ,PaymentMethod
  478. ,rtt.id
  479. ,dbo.decryptDb( controlNo) controlNo
  480. ,SenderName = ISNULL(ts.fullname, ts.firstname + ' ' + ts.lastname1)
  481. ,ReceiverName = rtt.receiverName
  482. ,FORMAT(createdDate, 'dd MMMM, yyyy') AS tranDate
  483. ,rtt.customerRate
  484. ,[Status] = CASE
  485. WHEN payStatus = 'Paid'
  486. THEN 'Paid'
  487. WHEN tranStatus = 'Cancel'
  488. OR payStatus = 'Cancel'
  489. THEN 'Cancel'
  490. ELSE 'PROCESSING'
  491. END
  492. ,errorCode = 0
  493. ,msg = 'Success'
  494. FROM dbo.remitTranTemp(NOLOCK) rtt
  495. INNER JOIN dbo.tranSendersTemp ts(NOLOCK) ON ts.tranid = rtt.id
  496. WHERE rtt.id = @id
  497. END
  498. ELSE IF @flag = 'cust-detail'
  499. BEGIN
  500. SELECT rt.tranStatus AS tranStatus
  501. ,rt.pAmt AS nprAmt
  502. ,CONCAT (
  503. RI.firstName
  504. ,' '
  505. ,RI.middleName
  506. ,' '
  507. ,RI.lastName1
  508. ) AS FullName
  509. ,rt.id AS tranId
  510. ,rt.createdDate AS tranDate
  511. ,tr.address AS address
  512. ,ISNULL(tr.mobile, RI.mobile) AS mobile
  513. ,rt.cAmt AS collAmt
  514. ,rt.serviceCharge AS serviceCharge
  515. ,rt.rewardPoints AS customerPremium
  516. ,rt.tAmt AS sentAmt
  517. ,rt.customerRate AS exRate
  518. ,rt.pAmt AS payoutAmt
  519. ,rt.pAgentName AS pAgent
  520. ,errorCode = 0
  521. ,msg = 'Success'
  522. FROM receiverInformation RI(NOLOCK)
  523. LEFT JOIN tranReceivers tr(NOLOCK) ON tr.id = RI.receiverId
  524. LEFT JOIN remitTran rt(NOLOCK) ON rt.id = tr.tranId
  525. WHERE RI.receiverId = @id
  526. END
  527. ELSE IF @Flag = 'CustomerTxn-all'
  528. BEGIN
  529. select * from (
  530. SELECT Id = rt.id
  531. ,recName = rt.receiverName
  532. ,recAccNum = rt.accountNo
  533. ,Amount = pAmt
  534. ,tAmount = tAmt
  535. ,dbo.decryptDb( controlNo) controlNo
  536. ,sendDate = CONVERT(varchar(10), rt.createdDate, 120)
  537. --,STATUS = CASE
  538. -- WHEN rt.tranStatus = 'Cancel'
  539. -- THEN 'CANCELLED'
  540. -- WHEN rt.tranStatus = 'Payment'
  541. -- AND rt.payStatus = 'Unpaid'
  542. -- AND rt.paymentMethod = 'Bank Deposit'
  543. -- THEN 'AWAITING PAYMENT'
  544. -- WHEN rt.tranStatus = 'Payment'
  545. -- AND rt.payStatus = 'Post'
  546. -- AND rt.paymentMethod = 'Cash Payment'
  547. -- THEN 'READY TO COLLECT'
  548. -- WHEN rt.tranStatus = 'Payment'
  549. -- AND rt.payStatus = 'Post'
  550. -- AND rt.paymentMethod = 'Bank Deposit'
  551. -- THEN 'PROCESSING'
  552. -- ELSE UPPER(rt.tranStatus)
  553. -- END
  554. --,TransactionDay = DATEPART(DAY, createdDate)
  555. --,TransactionMonth = DATENAME(MONTH, createdDate)
  556. ,PaymentMethod
  557. ,rt.pCountry
  558. --,PBankName
  559. --,PCurrency = payoutCurr
  560. ,errorCode = 0
  561. ,msg = 'Success'
  562. ,rt.createdDate
  563. FROM dbo.remitTran(NOLOCK) rt
  564. INNER JOIN dbo.tranSenders s(NOLOCK) ON s.tranid = rt.id
  565. WHERE s.customerId = @id
  566. UNION ALL
  567. SELECT Id = rtt.id
  568. ,recName = rtt.receiverName
  569. ,recAccNum = rtt.accountNo
  570. ,Amount = pAmt
  571. ,tAmount = tAmt
  572. ,dbo.decryptDb( controlNo) controlNo
  573. ,sendDate = CONVERT(varchar(10), rtt.createdDate, 120)
  574. --,STATUS = CASE
  575. -- WHEN payStatus = 'Paid'
  576. -- THEN 'Paid'
  577. -- WHEN tranStatus = 'Cancel'
  578. -- OR payStatus = 'Cancel'
  579. -- THEN 'Cancel'
  580. -- ELSE 'PROCESSING'
  581. -- END
  582. --,TransactionDay = DATEPART(DAY, createdDate)
  583. --,TransactionMonth = DATENAME(MONTH, createdDate)
  584. ,PaymentMethod
  585. ,rtt.pCountry
  586. --,PBankName
  587. --,PCurrency = payoutCurr
  588. ,errorCode = 0
  589. ,msg = 'Success'
  590. ,rtt.createdDate
  591. FROM dbo.remitTranTemp(NOLOCK) rtt
  592. INNER JOIN dbo.tranSendersTemp ts(NOLOCK) ON ts.tranid = rtt.id
  593. WHERE ts.customerId = @id
  594. )dum
  595. ORDER BY dum.createdDate desc
  596. END
  597. ELSE IF @Flag = 'CustomerReceiver-all'
  598. BEGIN
  599. SELECT Id = receiverId
  600. ,Name = FULLNAME
  601. ,Country = country
  602. ,Mobile
  603. ,TransactionType = SM.typeTitle
  604. ,errorCode = 0
  605. ,msg = 'Success'
  606. FROM receiverInformation RI(NOLOCK)
  607. INNER JOIN serviceTypeMaster SM(NOLOCK) ON SM.serviceTypeId = RI.paymentMode
  608. WHERE Ri.customerId = @id order by RI.createdDate desc
  609. END
  610. ELSE IF @Flag = 'editReceiver-detail'
  611. BEGIN
  612. print 'rr'
  613. SELECT Id = receiverId
  614. ,FirstName = firstName
  615. ,middleName = middleName
  616. ,LastName1 = lastName1
  617. ,relationship = ISNULL(relationship,'')
  618. ,Country = CM.CountryId
  619. ,address = ISNULL(address, '')
  620. ,city = ISNULL(city,'')
  621. ,zipCode = ISNULL(zipCode,'')
  622. ,mobile = ISNULL(mobile,'')
  623. ,email = ISNULL(email,'')
  624. --,paymentMode = ISNULL(STM.typeTitle,'')
  625. --,idType = ISNULL(sdv.detailTitle,'')
  626. ,paymentMode = ISNULL(paymentMode,'')
  627. ,idType = ISNULL(idType,'')
  628. ,idNumber = ISNULL(idNumber,'')
  629. ,bank = ISNULL(payOutPartner, '')
  630. ,branch = ISNULL(bankLocation,'')
  631. ,accountNum = ISNULL(receiverAccountNo,'')
  632. ,errorCode = 0
  633. ,msg = 'Success'
  634. FROM receiverInformation RI(NOLOCK)
  635. LEFT JOIN countryMaster CM(NOLOCK) ON CM.countryName = RI.country
  636. LEFT JOIN serviceTypeMaster STM ON RI.paymentMode = stm.serviceTypeId
  637. LEFT JOIN staticDataValue sdv ON RI.idType = sdv.valueId
  638. WHERE receiverId = @id
  639. SELECT '0' errorCode ,'Receiver fetched Successfully.' msg ,id = @id;
  640. END
  641. ELSE IF @Flag = 'editCustomerId-byId'
  642. BEGIN
  643. SELECT Id = customerId
  644. ,idType = ISNULL( idType,'')
  645. ,idNumber = ISNULL( idNumber,'')
  646. ,idExpiryDate = CONVERT(varchar(10), ISNULL(idExpiryDate , ''), 103)
  647. ,idIssueDate = CONVERT(varchar(10), ISNULL(idIssueDate , ''), 103)
  648. ,idIssueCountry = ISNULL( idIssueCountry, '')
  649. ,errorCode = 0
  650. ,msg = 'Success'
  651. FROM customerMaster
  652. WHERE customerId = CAST(@id AS INT)
  653. --SELECT '0' errorCode ,'Receiver fetched Successfully.' msg ,id =CAST(@id AS INT);
  654. END
  655. ELSE IF @Flag = 'editCustomerAdd-byId'
  656. BEGIN
  657. SELECT Id = customerId
  658. ,zipCode = ISNULL(zipCode, '')
  659. ,errorCode = 0
  660. ,msg = 'Success'
  661. FROM customerMaster
  662. WHERE customerId = CAST(@id AS INT)
  663. END
  664. END TRY
  665. BEGIN CATCH
  666. SET @ErrorMsg = 'Internal Server Error: ' + ERROR_MESSAGE()
  667. SELECT errorCode = 1
  668. ,msg = @ErrorMsg
  669. ,id = NULL
  670. END CATCH