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.

636 lines
50 KiB

9 months ago
9 months ago
8 months ago
9 months ago
9 months ago
8 months ago
9 months ago
8 months ago
9 months ago
8 months ago
9 months ago
8 months ago
9 months ago
8 months ago
9 months ago
8 months ago
9 months ago
8 months ago
9 months ago
8 months ago
9 months ago
8 months ago
9 months ago
8 months ago
9 months ago
8 months ago
9 months ago
  1. USE [FastMoneyPro_Remit]
  2. GO
  3. /****** Object: StoredProcedure [dbo].[proc_GetHoldedTxnForApprovedByAdminCompliance] Script Date: 2/6/2024 10:04:21 AM ******/
  4. SET ANSI_NULLS ON
  5. GO
  6. SET QUOTED_IDENTIFIER ON
  7. GO
  8. -- =============================================
  9. -- Author: <Author,Anoj Kattel>
  10. -- Create date: <Create Date,2019/04/23>
  11. -- Description: <Description,This sp is used for get transaction going for approv by admin>
  12. -- Modified on: 2021/06/03 -> Add mapping for Dongav2
  13. -- -> Add mapping for BOC
  14. --#5402 fix REMITTENCETYPE for BOC
  15. --EXEC proc_GetHoldedTxnForApprovedByAdminCompliance @user = 'scheduler', @tranId = '100644593', @callFro = null
  16. --select * FROM remittran where holdtranid='10385635'
  17. -- =============================================
  18. ALTER PROCEDURE [dbo].[proc_GetHoldedTxnForApprovedByAdminCompliance]
  19. (
  20. -- Add the parameters for the stored procedure here
  21. @user VARCHAR(50),
  22. @tranId VARCHAR(100),
  23. @callFro VARCHAR(30)
  24. )
  25. AS
  26. BEGIN
  27. -- SET NOCOUNT ON added to prevent extra result sets from
  28. -- interfering with SELECT statements.
  29. -- #9387 - Cebuana
  30. -- #12184 - Wing Cambodia Integration
  31. SET NOCOUNT ON;
  32. DECLARE @PartnerId VARCHAR(100),
  33. @tranStatus VARCHAR(100)
  34. SELECT @PartnerId=pSuperAgent,@tranStatus=tranStatus FROM dbo.remitTran WHERE id=@tranId
  35. --IF @tranStatus <> 'Hold'
  36. --BEGIN
  37. --IF @callFro!='txnHoldRelease'
  38. -- BEGIN
  39. -- SELECT 'NotForTPAPI' ErrorCode, @tranStatus msg,@tranId id
  40. -- END
  41. --END
  42. BEGIN TRY
  43. IF @PartnerId='394130' --- for transfast
  44. BEGIN
  45. SELECT DISTINCT
  46. RTT.id tranId
  47. ,'transfast' processId
  48. ,RTT.createdDate txnDate
  49. ,AU.userName userName
  50. ,ISNULL(am.parentId,0) partnerId
  51. ,ISNULL(cm.customerId,0) customerId
  52. ,isFirstTran 'Y'
  53. ,'' sfirstName
  54. ,'' smiddleName
  55. ,'' slastName1
  56. ,'' slastName2
  57. ,CM.fullName sfullName
  58. ,CM.idIssueDate sissuedDate
  59. ,CM.idExpiryDate svalidDate
  60. ,CM.dob sdob
  61. ,TST.email semail
  62. ,CASE WHEN SCC.CITY_CODE = '113179' THEN '113071'
  63. ELSE SCC.CITY_CODE END scity
  64. ,CASE WHEN SSC.STATE_CODE = 'JP037' THEN 'JP036'
  65. ELSE SSC.STATE_CODE END sstate
  66. --,SSC.STATE_CODE sstate
  67. ,CM.zipCode szipCode
  68. ,SNCC.countryCode snativeCountry
  69. ,CASE CM.idType
  70. WHEN 'Business Registation' THEN 'BZ'
  71. WHEN 'DRIVERS LICENSE' THEN 'DL'
  72. WHEN 'National ID' THEN 'G2'
  73. WHEN 'PASSPORT' THEN 'PA'
  74. WHEN 'Tohon' THEN 'BZ'
  75. ELSE 'PA'
  76. END sidType --- map idtype name and code with transfast sender idtype value
  77. ,CM.idNumber sidNumber
  78. ,REPLACE(CM.mobile,'+','') smobile
  79. ,CASE
  80. WHEN CM.customerType='4700'
  81. THEN 1
  82. ELSE 0 END IsIndividual
  83. ,ISNULL(CM.address,CM.city) saddress
  84. ,ISNULL(cm.occupation,0) occupationId
  85. ,ISNULL(OCU.detailTitle,0) occupationName
  86. ,'JP' sCountry
  87. --------- receiver details
  88. ,ISNULL(TRT.id,0) receiverId
  89. ,TRT.firstName rfirstName
  90. ,TRT.middleName rmiddleName
  91. ,TRT.lastName1 rlastName1
  92. ,TRT.firstName
  93. +ISNULL(' ' +TRT.middleName,'')
  94. +ISNULL(' '+TRT.lastName1,'')
  95. +ISNULL(' '+TRT.lastName2,'')
  96. rfullName
  97. ,CASE RCON.countryCode
  98. WHEN 'LK' THEN --------- for sri lanka
  99. CASE TRT.idType
  100. WHEN 'Driver License' THEN '188'
  101. WHEN 'Business Registation' THEN '189'
  102. WHEN 'National ID' THEN '195'
  103. WHEN 'Passport' THEN '197'
  104. ELSE '195'
  105. END
  106. WHEN 'ID' THEN -- indonesia
  107. CASE TRT.idType
  108. WHEN 'Driver License' THEN '286'
  109. WHEN 'Passport' THEN '287'
  110. WHEN 'National ID' THEN '288'
  111. ELSE '287'
  112. END
  113. WHEN 'PH' THEN -- PHILIPPINES
  114. CASE TRT.idType
  115. WHEN 'Tohon' THEN '307'
  116. WHEN 'Driver License' THEN '310'
  117. WHEN 'Passport' THEN '316'
  118. WHEN 'Alien Registration Card' THEN '326'
  119. ELSE '316'
  120. END
  121. WHEN 'PK' THEN --- pakistan
  122. CASE TRT.idType
  123. WHEN 'Passport' THEN '270'
  124. WHEN 'Business Registation' THEN '272'
  125. WHEN 'Driver License' THEN '269'
  126. WHEN 'National ID' THEN '271'
  127. ELSE '270'
  128. END
  129. WHEN 'BD' THEN --- bangladesh
  130. CASE TRT.idType
  131. WHEN 'Passport' THEN '12'
  132. WHEN 'National ID' THEN '13'
  133. WHEN 'Driver License' THEN '14'
  134. WHEN 'Business Registation' THEN '16'
  135. ELSE '430'
  136. END
  137. WHEN 'IN' THEN --- india
  138. CASE TRT.idType
  139. WHEN 'Passport' THEN '136'
  140. WHEN 'Business Registation' THEN '137'
  141. WHEN 'Alien Registration Card' THEN '140'
  142. WHEN 'Driver License' THEN '142'
  143. WHEN 'National ID' THEN '329'
  144. ELSE '136'
  145. END
  146. END
  147. ridType --- map with transfast receiver idtype id code
  148. ,TRT.idNumber ridNumber
  149. ,TRT.validDate rvalidDate
  150. ,TRT.dob rdob
  151. ,TRT.homePhone rhomePhone
  152. ,TRT.mobile rmobile
  153. ,RNC.countryCode rnativeCountry
  154. ,ISNULL(TRT.city,TRT.address) rcity
  155. ,TRT.address raddress
  156. ,TRT.email remail
  157. ,raccountNo = CASE WHEN RTT.paymentMethod = 'Bank Deposit' THEN RTT.accountNo ELSE '' END
  158. ,RCON.countryCode rcountry
  159. ,'' branchId
  160. --,CASE RTT.paymentMethod
  161. -- WHEN 'Bank Deposit' THEN APBL.BRANCH_CODE
  162. -- WHEN 'Cash Payment' THEN ABBL.BRANCH_CODE1 END branchId -------- Need To Map With Transfast PayingBranchId
  163. ,CASE RTT.paymentMethod
  164. WHEN 'Bank Deposit' THEN PBD.PAYER_CODE
  165. WHEN 'Cash Payment' THEN ABL.BANK_CODE1 END payerId -------- Need To Map With Transfast PayerId
  166. ,TRT.branchName branchName
  167. ,AU.city city
  168. ,ISNULL(RTT.pAgent,0) pAgent
  169. ,RTT.pAgentName pAgentName
  170. ,RTT.pBankType pBankType
  171. ,CASE RTT.paymentMethod
  172. WHEN 'Bank Deposit' THEN ISNULL(ABL.BANK_CODE1,'')
  173. ELSE '' END pBank
  174. ,ISNULL(abl.BANK_CODE2,0) pBankLocation
  175. ,CASE RTT.paymentMethod
  176. WHEN 'Bank Deposit' THEN ISNULL(ABBL.BRANCH_CODE1,'')
  177. ELSE '' END pBankBranchId
  178. ,RTT.pBankName pBankName
  179. ,RTT.payoutCurr payoutCurr
  180. ,RTT.collCurr collCurr
  181. ,ISNULL(RTT.cAmt,0) cAmt
  182. ,ISNULL(RTT.pAmt,0) pAmt
  183. ,ISNULL(RTT.tAmt,0) tAmt
  184. ,serviceCharge serviceCharge
  185. ,ISNULL(RTT.pAgentComm,0) pAgentComm
  186. ,CASE RCON.countryCode
  187. WHEN 'LK' THEN
  188. CASE RTT.purposeOfRemit
  189. WHEN 'Family maintenance' THEN '1'
  190. WHEN 'Educational expenses' THEN '2'
  191. WHEN 'Medical Expenses' THEN '3'
  192. WHEN 'Business travel' THEN '7'
  193. WHEN 'Trading' THEN '14'
  194. WHEN 'Savings' THEN '18'
  195. WHEN 'Purchase of land / property' THEN '23'
  196. WHEN 'Utility payment' THEN '24'
  197. WHEN 'Rent' THEN '25'
  198. WHEN 'Personal travels and tours' THEN '26'
  199. WHEN 'Trading' THEN '27'
  200. WHEN 'Salary / Commission' THEN '29'
  201. WHEN 'Loan payment / Interest' THEN '30'
  202. ELSE '1'
  203. END
  204. WHEN 'ID' THEN
  205. CASE RTT.purposeOfRemit
  206. WHEN 'Family maintenance' THEN '1'
  207. WHEN 'Educational expenses' THEN '2'
  208. WHEN 'Medical Expenses' THEN '3'
  209. WHEN 'Purchase of land / property' THEN '9'
  210. WHEN 'Trading' THEN '14'
  211. WHEN 'Savings' THEN '18'
  212. WHEN 'Utility payment' THEN '24'
  213. WHEN 'Personal travels and tours' THEN '26'
  214. WHEN 'Loan payment / Interest' THEN '30'
  215. ELSE '1'
  216. END
  217. WHEN 'PH' THEN
  218. CASE RTT.purposeOfRemit
  219. WHEN 'Family maintenance' THEN '1'
  220. WHEN 'Educational expenses' THEN '2'
  221. WHEN 'Medical Expenses' THEN '3'
  222. WHEN 'Business travel' THEN '7'
  223. WHEN 'Trading' THEN '14'
  224. WHEN 'Savings' THEN '18'
  225. WHEN 'Purchase of land / property' THEN '23'
  226. WHEN 'Utility payment' THEN '24'
  227. WHEN 'Personal travels and tours' THEN '26'
  228. WHEN 'Trading' THEN '27'
  229. WHEN 'Salary / Commission' THEN '29'
  230. WHEN 'Loan payment / Interest' THEN '30'
  231. ELSE '1'
  232. END
  233. WHEN 'PK' THEN
  234. CASE RTT.purposeOfRemit
  235. WHEN 'Family maintenance' THEN '1'
  236. WHEN 'Educational expenses' THEN '2'
  237. WHEN 'Medical Expenses' THEN '3'
  238. WHEN 'Trading' THEN '14'
  239. WHEN 'Savings' THEN '18'
  240. WHEN 'Purchase of land / property' THEN '23'
  241. WHEN 'Utility payment' THEN '24'
  242. WHEN 'Personal travels and tours' THEN '26'
  243. WHEN 'Loan payment / Interest' THEN '30'
  244. ELSE '1'
  245. END
  246. WHEN 'BD' THEN
  247. CASE RTT.purposeOfRemit
  248. WHEN 'Family maintenance' THEN '1'
  249. WHEN 'Educational expenses' THEN '2'
  250. WHEN 'Medical Expenses' THEN '3'
  251. WHEN 'Purchase of land / property' THEN '9'
  252. WHEN 'Trading' THEN '14'
  253. WHEN 'Savings' THEN '18'
  254. WHEN 'Utility payment' THEN '24'
  255. WHEN 'Personal travels and tours' THEN '26'
  256. WHEN 'Loan payment / Interest' THEN '30'
  257. ELSE '1'
  258. END
  259. WHEN 'IN' THEN
  260. CASE RTT.purposeOfRemit
  261. WHEN 'Family maintenance' THEN '1'
  262. WHEN 'Savings' THEN '18'
  263. WHEN 'Purchase of land / property' THEN '23'
  264. WHEN 'Educational expenses' THEN '24'
  265. WHEN 'Rent' THEN '25'
  266. WHEN 'Personal travels and tours' THEN '26'
  267. WHEN 'Trading' THEN '27'
  268. WHEN 'Utility payment' THEN '28'
  269. WHEN 'Salary / Commission' THEN '29'
  270. WHEN 'Loan payment / Interest' THEN '30'
  271. WHEN 'Medical Expenses' THEN '32'
  272. ELSE '1'
  273. END
  274. END purposeOfRemit ----------- Map With Transfast code
  275. ,CASE RTT.sourceOfFund
  276. WHEN 'Own business' THEN '1'
  277. WHEN 'Business' THEN '2'
  278. WHEN 'Salary / Wages' THEN '3'
  279. WHEN 'Return from Investment' THEN '4'
  280. WHEN 'Loan from bank' THEN '5'
  281. WHEN 'Lottery' THEN '6'
  282. WHEN 'Part time job' THEN '7'
  283. WHEN 'Pension' THEN '8'
  284. WHEN 'Savings or accumulated' THEN '10'
  285. ELSE '9'
  286. END sourceOfFund
  287. ,rel.detailTitle relationName
  288. ,cm.remarks remarks
  289. ,ISNULL(RTT.sAgent,0) sAgent
  290. ,RTT.sAgentName sAgentName
  291. ,ISNULL(RTT.sSuperAgent,0) sSuperAgent
  292. ,cm.ipAddress ipAddress
  293. ,AU.countryId countryId
  294. ,RSC.STATE_CODE rstate ----- Receiver State Code
  295. ,ISNULL(RTT.sBranch,0) sBranch
  296. ,RTT.pLocation pLocation
  297. ,CASE RTT.paymentMethod
  298. WHEN 'Bank Deposit' THEN 'C'
  299. WHEN 'Cash Payment' THEN '2'
  300. END paymentMethod -------- map with transfast payoutmethod id
  301. ,dbo.decryptDb(RTT.controlNo) controlNo
  302. ,RCC.CITY_CODE rcityCode ----- Receiver City Code
  303. ,RTC.TOWN_CODE rTownCode ----- Receiver Town Code
  304. ,cm.sessionId sessionId
  305. ,'true' IsRealtime
  306. ,bankAccountNo = CASE WHEN RTT.paymentMethod = 'Bank Deposit' THEN RTT.accountNo ELSE '' END
  307. ,'CA' formOfPaymentId
  308. ,CM.SSNNO ssnno
  309. ,RTT.customerrate Rate
  310. ,'N' IsRealtime
  311. FROM remitTran RTT WITH(NOLOCK)
  312. INNER JOIN dbo.tranSenders TST(NOLOCK) ON TST.TRANID = RTT.ID
  313. INNER JOIN customerMaster CM(NOLOCK) ON CM.customerId = TST.customerId
  314. INNER JOIN dbo.tranReceivers TRT(NOLOCK) ON TRT.TRANID = RTT.id
  315. LEFT JOIN applicationUsers AU(NOLOCK) ON AU.USERNAME = RTT.CREATEDBY
  316. LEFT JOIN dbo.agentMaster AM(NOLOCK) ON AM.agentId=RTT.pAgent
  317. LEFT JOIN API_BANK_LIST ABL (NOLOCK) ON ABL.BANK_ID=RTT.pBank
  318. LEFT JOIN dbo.API_BANK_BRANCH_LIST ABBL (NOLOCK) ON ABBL.BRANCH_ID=RTT.pBankBranch -- OR ABBL.BRANCH_NAME=RTT.pBankBranchName
  319. LEFT JOIN dbo.staticDataValue OCU (NOLOCK) ON OCU.valueId=cm.occupation
  320. LEFT JOIN dbo.staticDataValue REL (NOLOCK) ON REL.detailTitle=RTT.relWithSender
  321. --LEFT JOIN dbo.staticDataValue IDT (NOLOCK) ON IDT.valueId=TRT.idType
  322. LEFT JOIN dbo.countryStateMaster CSM(NOLOCK) ON CSM.stateId=cm.state
  323. LEFT JOIN dbo.API_CITY_LIST SCC (NOLOCK) ON SCC.CITY_NAME=CM.city
  324. LEFT JOIN dbo.API_STATE_LIST SSC (NOLOCK) ON SSC.STATE_ID=SCC.STATE_ID
  325. LEFT JOIN dbo.API_STATE_LIST RSC (NOLOCK) ON RSC.STATE_NAME=TRT.STATE
  326. LEFT JOIN dbo.API_CITY_LIST RCC (NOLOCK) ON SCC.CITY_NAME=TRT.city
  327. LEFT JOIN dbo.API_TOWN_LIST RTC (NOLOCK) ON RTC.TOWN_ID=RTT.pLocation
  328. LEFT JOIN dbo.countryMaster SNCC (NOLOCK) ON SNCC.countryId=CM.country
  329. LEFT JOIN dbo.countryMaster RCON (NOLOCK) ON RCON.countryName=TRT.country
  330. LEFT JOIN dbo.countryMaster RNC (NOLOCK) ON RNC.countryName=TRT.NativeCountry OR RNC.countryId = TRT.NativeCountry
  331. LEFT JOIN dbo.PAYER_BANK_DETAILS PBD(NOLOCK) ON PBD.PAYER_ID = RTT.PayerId
  332. --LEFT JOIN dbo.API_PAYOUT_LOACTION APL(NOLOCK) ON APL.Id=RTT.PayerId
  333. --LEFT JOIN dbo.API_PAYOUT_BRANCH_LOACTION APBL (NOLOCK) ON APBL.Id=RTT.PayerBranchId
  334. WHERE RTT.id =@tranId
  335. END
  336. IF @PartnerId= '394397' ----- For GME NEPAL
  337. BEGIN
  338. SELECT
  339. RTT.id tranId ----
  340. ,'gmenepal' processId
  341. ,CONVERT(VARCHAR, RTT.createdDate, 110) txnDate
  342. ,AU.userName userName -- notes -- Filds are use for jme nepal send model
  343. ,ISNULL(AM.parentId,0) partnerId ---- use for to get thirdparty api partner services
  344. ,ISNULL(CM.customerId,0) customerId
  345. ,isFirstTran 'Y' ----
  346. ,'' sfirstName
  347. ,'' smiddleName
  348. ,'' slastName1
  349. ,'' slastName2
  350. ,CM.fullName sfullName --
  351. ,TST.address saddress --
  352. ,CM.mobile smobile --
  353. ,tst.city scity --
  354. ,RTT.sCountry sCountry --
  355. ,TST.idType sidType --
  356. ,TST.idNumber sidNumber --
  357. ,TRT.fullName rfullName --
  358. ,TRT.address raddress --
  359. ,TRT.mobile rmobile --
  360. ,ISNULL(TRT.city,TRT.address) rcity --
  361. ,TRT.country rcountry --
  362. ,RTT.sourceOfFund sourceOfFund --
  363. ,RTT.relwithsender relationName --
  364. ,RTT.purposeOfRemit purposeOfRemit --
  365. ,ISNULL(RTT.cAmt,0) cAmt --
  366. ,ISNULL(RTT.pAmt,0) pAmt --
  367. ,ISNULL(RTT.tAmt,0) tAmt --
  368. ,RTT.paymentMethod paymentMethod --
  369. ,RTT.pBankName pBankName --
  370. ,ISNULL(PBID.BANK_CODE1,0) pBank --
  371. ,pBankLocation = CASE WHEN PBID.BANK_CODE1='11006083' THEN PBID.BANK_CODE2 ELSE ISNULL(PBBID.BRANCH_CODE1,'0') END
  372. ,ISNULL(PBBID.BRANCH_NAME,'') pBankBranchName --
  373. ,raccountNo = CASE WHEN RTT.paymentMethod = 'Bank Deposit' THEN RTT.accountNo ELSE '' END
  374. ,CM.idIssueDate sissuedDate --
  375. ,CM.idExpiryDate svalidDate --
  376. ,CM.dob sdob --
  377. ,'' semail
  378. ,'' szipCode
  379. ,CM.nativeCountry snativeCountry --
  380. ,0 occupationId
  381. ,CASE WHEN CM.occupation = '11383' THEN CM.occupationother ELSE ISNULL(OCU.detailTitle,0) END occupationName --
  382. --------- receiver details
  383. ,'' receiverId
  384. ,'' rfirstName
  385. ,'' rmiddleName
  386. ,'' rlastName1
  387. ,'' ridType
  388. ,'' ridNumber
  389. ,'' rvalidDate
  390. ,'' rdob
  391. ,'' rhomePhone
  392. --,RE.countryCode
  393. ,'' rnativeCountry
  394. ,'' remail
  395. ,'' branchId
  396. ,'' branchName
  397. ,'' city
  398. ,0 pAgent
  399. ,'' pAgentName
  400. ,'' pBankType
  401. ,RTT.payoutCurr
  402. ,RTT.collCurr
  403. ,RTT.SERVICECHARGE serviceCharge --
  404. ,'' pAgentComm
  405. ,'' relationId
  406. ,'' remarks
  407. ,0 sAgent
  408. ,'' sAgentName
  409. ,0 sSuperAgent
  410. ,'' ipAddress
  411. ,0 countryId
  412. ,'' rstate
  413. ,0 sBranch
  414. ,'' pLocation
  415. ,dbo.decryptDb(RTT.controlNo) controlNo --
  416. ,0 exRate
  417. ,'' rcityCode
  418. ,CM.sessionId sessionId ----
  419. ,'true' IsRealtime ----
  420. ,bankAccountNo = CASE WHEN RTT.paymentMethod = 'Bank Deposit' THEN RTT.accountNo ELSE '' END
  421. ,'Y' IsRealtime
  422. ,RTT.company exRateConfirmId
  423. ,RTT.pCurrCostRate SettlementDollarRate
  424. FROM remitTran RTT WITH(NOLOCK)
  425. INNER JOIN dbo.tranSenders TST(NOLOCK) ON TST.TRANID = RTT.ID
  426. INNER JOIN customerMaster CM(NOLOCK) ON CM.customerId = TST.customerId
  427. INNER JOIN dbo.tranReceivers TRT(NOLOCK) ON TRT.TRANID = RTT.ID
  428. LEFT JOIN applicationUsers AU(NOLOCK) ON AU.USERNAME = RTT.CREATEDBY
  429. INNER JOIN dbo.agentMaster AM(NOLOCK) ON AM.agentId=RTT.pAgent
  430. LEFT JOIN API_BANK_LIST PBID (NOLOCK) ON PBID.BANK_ID=RTT.pBank
  431. LEFT JOIN dbo.API_BANK_BRANCH_LIST PBBID (NOLOCK) ON PBBID.BRANCH_ID=RTT.pBankBranch
  432. LEFT JOIN dbo.staticDataValue OCU (NOLOCK) ON OCU.valueId=TST.occupation
  433. LEFT JOIN dbo.staticDataValue REL (NOLOCK) ON REL.valueId=CM.relationId
  434. WHERE RTT.id = @tranId
  435. END
  436. IF @PartnerId= '394449' ----- For GCC REMIT
  437. BEGIN
  438. SELECT
  439. RTT.id tranId ----
  440. ,'gccremit' processId
  441. ,CONVERT(VARCHAR, RTT.createdDate, 110) txnDate
  442. ,AU.userName userName -- notes -- Filds are use for jme nepal send model
  443. ,ISNULL(AM.parentId,0) partnerId ---- use for to get thirdparty api partner services
  444. ,ISNULL(CM.customerId,0) customerId
  445. ,isFirstTran 'Y' ----
  446. ,CM.firstName sfirstName
  447. ,CM.middleName smiddleName
  448. ,CM.lastName1 slastName1
  449. ,CM.lastName2 slastName2
  450. ,CM.fullName sfullName --
  451. ,TST.address saddress --
  452. ,CM.mobile smobile --
  453. ,CM.email semail
  454. ,tst.city scity --
  455. ,'GB' sCountry --
  456. ,CASE TST.idType
  457. WHEN 'PASSPORT' THEN '2'
  458. WHEN 'DRIVER LICENSE' THEN '4'
  459. WHEN 'Biometric Residence Permit' THEN '5'
  460. ELSE '2'
  461. END As sidType --
  462. ,TST.idNumber sidNumber --
  463. ,TRT.fullName rfullName --
  464. ,TRT.address raddress --
  465. ,TRT.mobile rmobile --
  466. ,ISNULL(TRT.city,TRT.address) rcity --
  467. ,TRT.country rcountry --
  468. ,CASE RTT.sourceOfFund
  469. WHEN 'Business Income' THEN '5'
  470. WHEN 'Salary' THEN '2'
  471. ELSE '5'
  472. END sourceOfFund
  473. --,RTT.relwithsender relationName --
  474. , CASE RTT.relwithsender
  475. WHEN 'Business Partner' THEN '7' -- RTR001 FAMILY
  476. WHEN 'Friend' THEN '3'
  477. WHEN 'Parents' THEN '1'
  478. WHEN 'Self' THEN '5'
  479. WHEN 'Husband/Wife' THEN '12'
  480. ELSE '1'
  481. END relationName --
  482. ,CASE RTT.purposeOfRemit
  483. WHEN 'Family Support' THEN '1'
  484. WHEN 'Education Support' THEN '4'
  485. WHEN 'Investment' THEN '8'
  486. WHEN 'Loan Payment' THEN '9'
  487. WHEN 'Medical Support' THEN '2'
  488. WHEN 'Salary Payments' THEN '10'
  489. WHEN 'Personal Savings' THEN '6'
  490. ELSE '1'
  491. END AS purposeOfRemit
  492. ,ISNULL(RTT.cAmt,0) cAmt --
  493. ,ISNULL(RTT.pAmt,0) pAmt --
  494. ,ISNULL(RTT.tAmt,0) tAmt --
  495. ,CASE
  496. WHEN RTT.pCountry = 'INDIA' and RTT.paymentMethod = 'Bank Deposit' THEN '9'
  497. WHEN RTT.pCountry = 'BANGLADESH' and RTT.paymentMethod = 'Bank Deposit' THEN '3'
  498. WHEN RTT.pCountry = 'HONG KONG' and RTT.paymentMethod = 'Bank Deposit' THEN '2'
  499. WHEN RTT.pCountry = 'PAKISTAN' and RTT.paymentMethod = 'Bank Deposit' THEN '6'
  500. WHEN RTT.pCountry = 'SINGAPORE' and RTT.paymentMethod = 'Bank Deposit' THEN '6'
  501. WHEN RTT.pCountry = 'SRI LANKA' and RTT.paymentMethod = 'Bank Deposit' THEN '2'
  502. WHEN RTT.pCountry = 'UNITED ARAB EMIRATES' and RTT.paymentMethod = 'Bank Deposit' THEN '2'
  503. WHEN RTT.pCountry = 'UNITED STATES OF AMERICA' and RTT.paymentMethod = 'Bank Deposit' THEN '3'
  504. WHEN RTT.pCountry = 'AUSTRIA' and RTT.paymentMethod = 'Bank Deposit' THEN ''
  505. --WHEN 'Cash Payment' THEN '1'
  506. --WHEN 'Mobile Wallet' THEN '!4'
  507. END paymentMethod
  508. ,RTT.pBankName pBankName --
  509. ,ISNULL(PBID.BANK_CODE1,0) pBank --
  510. ,pBankLocation = CASE WHEN PBID.BANK_CODE1='11006083' THEN PBID.BANK_CODE2 ELSE ISNULL(PBBID.BRANCH_CODE1,'0') END
  511. ,ISNULL(PBBID.BRANCH_NAME,'') pBankBranchName --
  512. ,raccountNo = CASE WHEN RTT.paymentMethod = 'Bank Deposit' THEN RTT.accountNo ELSE '' END
  513. ,CM.idIssueDate sissuedDate --
  514. ,CM.idExpiryDate svalidDate --
  515. ,CM.dob sdob --
  516. ,'' semail
  517. ,sCON.countryCode szipCode
  518. ,CM.nativeCountry snativeCountry --
  519. ,0 occupationId
  520. ,CASE WHEN CM.occupation = '11383' THEN CM.occupationother ELSE ISNULL(OCU.detailTitle,0) END occupationName --
  521. --------- receiver details
  522. --,'' receiverId
  523. --,'' rfirstName
  524. --,'' rmiddleName
  525. --,'' rlastName1
  526. ,ISNULL(TRT.id,0) receiverId
  527. ,TRT.firstName rfirstName
  528. ,TRT.middleName rmiddleName
  529. ,TRT.lastName1 rlastName1
  530. ,TRT.idType ridType
  531. ,'' ridNumber
  532. ,'' rvalidDate
  533. ,'' rdob
  534. ,'' rhomePhone
  535. --,RE.countryCode
  536. ,RCON.countryCode rnativeCountry
  537. ,TRT.email remail
  538. --,CASE when rtt.sCountry = 'INDIA' and branchId = 'INSII00002-9' then ''
  539. , CASE
  540. WHEN TRT.country = 'INDIA' THEN PBID.BANK_CODE2
  541. WHEN TRT.country = 'PAKISTAN' THEN PBID.BANK_CODE1
  542. WHEN TRT.country = 'BANGLADESH' THEN PBID.BANK_CODE2
  543. WHEN TRT.country = 'SRI LANKA' THEN PBID.BANK_CODE2
  544. END AS branchId
  545. --End branchid
  546. --,'INSII00002-9' branchId
  547. -- ,Branchid = CASE
  548. -- WHEN TRT.country = 'INDIA' then branchId = 'INSII00002-9'
  549. --WHEN TRT.country = 'Pakistan' then branchId = 'PKBOP00001-6'
  550. --END
  551. ,'' branchName
  552. ,'' city
  553. ,0 pAgent
  554. ,'' pAgentId
  555. ,PBBID.BRANCH_CODE1 pAgentName
  556. ,'' pBankType
  557. ,RTT.payoutCurr
  558. ,RTT.collCurr
  559. ,RTT.SERVICECHARGE serviceCharge --
  560. ,'' pAgentComm
  561. ,TRT.relationType relationId
  562. ,'' remarks
  563. ,0 sAgent
  564. ,'' sAgentName
  565. ,0 sSuperAgent
  566. ,'' ipAddress
  567. ,0 countryId
  568. ,'' rstate
  569. ,0 sBranch
  570. ,'' pLocation
  571. ,dbo.decryptDb(RTT.controlNo) controlNo --
  572. ,0 exRate
  573. ,'' rcityCode
  574. ,CM.sessionId sessionId ----
  575. ,'true' IsRealtime ----
  576. ,bankAccountNo = CASE WHEN RTT.paymentMethod = 'Bank Deposit' THEN RTT.accountNo ELSE '' END
  577. ,'Y' IsRealtime
  578. ,RTT.company exRateConfirmId
  579. ,RTT.pCurrCostRate SettlementDollarRate
  580. FROM remitTran RTT WITH(NOLOCK)
  581. INNER JOIN dbo.tranSenders TST(NOLOCK) ON TST.TRANID = RTT.ID
  582. INNER JOIN customerMaster CM(NOLOCK) ON CM.customerId = TST.customerId
  583. INNER JOIN dbo.tranReceivers TRT(NOLOCK) ON TRT.TRANID = RTT.ID
  584. LEFT JOIN applicationUsers AU(NOLOCK) ON AU.USERNAME = RTT.CREATEDBY
  585. INNER JOIN dbo.agentMaster AM(NOLOCK) ON AM.agentId=RTT.pAgent
  586. LEFT JOIN API_BANK_LIST PBID (NOLOCK) ON PBID.BANK_ID=RTT.pBank
  587. LEFT JOIN dbo.API_BANK_BRANCH_LIST PBBID (NOLOCK) ON PBBID.BRANCH_ID=RTT.pBankBranch
  588. LEFT JOIN dbo.staticDataValue OCU (NOLOCK) ON OCU.valueId=TST.occupation
  589. LEFT JOIN dbo.staticDataValue REL (NOLOCK) ON REL.valueId=CM.relationId
  590. LEFT JOIN dbo.countryMaster RCON (NOLOCK) ON RCON.countryName=TRT.Country
  591. LEFT JOIN dbo.countryMaster sCON (NOLOCK) ON sCON.countryName=TST.nativeCountry
  592. --LEFT JOIN countryMaster RCC (NOLOCK) ON RCC.countryId= RTT.ID
  593. WHERE RTT.id = @tranId
  594. END
  595. END TRY
  596. BEGIN CATCH
  597. IF @@TRANCOUNT > 0
  598. ROLLBACK TRANSACTION
  599. SELECT 1 error_code, ERROR_MESSAGE() mes, NULL id
  600. END CATCH
  601. END