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.

1066 lines
87 KiB

7 months ago
  1. USE [FastMoneyPro_Remit]
  2. GO
  3. /****** Object: StoredProcedure [dbo].[proc_GetHoldedTxnForApprovedByAdminCompliance] Script Date: 2/19/2024 6:35:59 PM ******/
  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='394132' --- for donga
  44. BEGIN
  45. SELECT RT.id tranId
  46. ,'donga' processId
  47. ,RT.createdDate txnDate
  48. ,RT.CREATEDBY userName
  49. ,RT.PSUPERAGENT partnerId
  50. ,S.CUSTOMERID customerId
  51. ,isFirstTran 'Y'
  52. ,CM.firstName sfirstName
  53. ,CM.middleName smiddleName
  54. ,CM.lastName1 slastName1
  55. ,CM.lastName2 slastName2
  56. ,CM.fullName sfullName
  57. ,CM.idIssueDate sissuedDate
  58. ,CM.idExpiryDate svalidDate
  59. ,CM.dob sdob
  60. ,CM.email semail
  61. ,CM.city scity
  62. ,CM.zipCode szipCode
  63. ,CM.nativeCountry snativeCountry
  64. ,CM.idType sidType
  65. ,CM.idNumber sidNumber
  66. ,CM.mobile smobile
  67. ,'' saddress
  68. ,0 occupationId
  69. ,'' occupationName
  70. ,R.CUSTOMERID receiverId
  71. ,R.fullName rfullName
  72. ,R.firstName rfirstName
  73. ,R.middleName rmiddleName
  74. ,R.lastName1 rlastName1
  75. ,R.idType ridType
  76. ,R.idNumber ridNumber
  77. ,R.validDate rvalidDate
  78. ,R.dob rdob
  79. ,R.homePhone rhomePhone
  80. ,R.mobile rmobile
  81. ,'' rnativeCountry
  82. ,ISNULL(R.city,R.address) rcity
  83. ,R.address raddress
  84. ,R.email remail
  85. ,raccountNo= CASE WHEN RT.paymentMethod = 'Bank Deposit' THEN RT.accountNo ELSE '' END
  86. ,R.country rcountry
  87. ,'' branchId
  88. ,'' branchName
  89. ,'' city
  90. ,ISNULL(RT.pAgent,0) pAgent
  91. ,RT.pAgentName pAgentName
  92. ,RT.pBankType pBankType
  93. ,ISNULL(abl.BANK_CODE1,0) pBank
  94. ,ISNULL(abl.BANK_CODE2,0) pBankLocation
  95. ,RT.pBankName pBankName
  96. ,RT.payoutCurr payoutCurr
  97. ,RT.collCurr collCurr
  98. ,ISNULL(RT.cAmt,0) cAmt
  99. ,ISNULL(RT.pAmt,0) pAmt
  100. ,ISNULL(RT.tAmt,0) tAmt
  101. ,0 serviceCharge
  102. ,ISNULL(RT.pAgentComm,0) pAgentComm
  103. --,RT.purposeOfRemit purposeOfRemit
  104. ,CASE RT.purposeOfRemit
  105. WHEN 'Donation' THEN '006'
  106. WHEN 'Family Support' THEN '005'
  107. WHEN 'Gift' THEN '008'
  108. WHEN 'Payment of Import Good' THEN '012'
  109. WHEN 'Self Saving' THEN '009'
  110. WHEN 'Tax Refund' THEN '014'
  111. ELSE '014' --Other (please kindly specify)
  112. END AS purposeOfRemit
  113. ,RT.sourceOfFund sourceOfFund
  114. ,ISNULL(CM.relationId,0) relationId
  115. , CASE RT.relwithsender
  116. WHEN 'Brother/Sister' THEN '002'
  117. WHEN 'Brother/Sister (In Law)' THEN '009'
  118. WHEN 'Cousin' THEN '005'
  119. WHEN 'Father' THEN '003'
  120. WHEN 'Father in law' THEN '005'
  121. WHEN 'Grand Mother/Grand Father' THEN '001'
  122. WHEN 'Mother' THEN '003'
  123. WHEN 'Mother in law' THEN '005'
  124. WHEN 'Nephew/Niece' THEN '001'
  125. WHEN 'Self' THEN '012'
  126. WHEN 'Son/Daughter' THEN '010'
  127. WHEN 'Son/Daughter (In Law)' THEN '009'
  128. WHEN 'Spouse (Husband or Wife)' THEN '006'
  129. WHEN 'Uncle/Aunt' THEN '004'
  130. ELSE '012' --Other (Please kindly specify)
  131. END AS relationName
  132. ,'' remarks
  133. ,ISNULL(RT.sAgent,0) sAgent
  134. ,RT.sAgentName sAgentName
  135. ,ISNULL(RT.sSuperAgent,0) sSuperAgent
  136. ,CM.ipAddress ipAddress
  137. ,CCM.COUNTRYID countryId --SENDING COUNTRY
  138. ,RT.sCountry sCountry
  139. ,ASL.STATE_CODE rstate
  140. ,ISNULL(RT.sBranch,0) sBranch
  141. ,'' pLocation
  142. ,RT.paymentMethod paymentMethod
  143. ,dbo.decryptDb(RT.controlNo) controlNo
  144. ,CASE LEN(ISNULL(ACL.CITY_CODE,'')) WHEN 3 THEN ACL.CITY_CODE ELSE '' END rcityCode
  145. ,CM.sessionId sessionId
  146. ,'true' IsRealtime
  147. ,bankAccountNo = CASE WHEN RT.paymentMethod = 'Bank Deposit' THEN RT.accountNo ELSE '' END
  148. ,'Y' IsRealtime
  149. , CASE ABL.TRANSFER_MODE
  150. WHEN 'RTA' THEN '1' ELSE '0' END IsAccValSupported
  151. FROM REMITTRAN RT(NOLOCK)
  152. INNER JOIN TRANSENDERS S(NOLOCK) ON S.TRANID = RT.ID
  153. INNER JOIN TRANRECEIVERS R(NOLOCK) ON R.TRANID = RT.ID
  154. INNER JOIN CUSTOMERMASTER CM(NOLOCK) ON CM.CUSTOMERID = S.CUSTOMERID
  155. LEFT JOIN API_BANK_LIST ABL(NOLOCK) ON RT.pBank = ABL.BANK_ID
  156. INNER JOIN COUNTRYMASTER CCM(NOLOCK) ON CCM.COUNTRYNAME = RT.SCOUNTRY
  157. LEFT JOIN dbo.API_STATE_LIST ASL (NOLOCK) ON asl.STATE_ID = RT.pState
  158. LEFT JOIN dbo.API_CITY_LIST acl (NOLOCK) ON acl.CITY_ID = RT.pDistrict
  159. WHERE RT.ID = @tranId
  160. END
  161. IF @PartnerId='394130' --- for transfast
  162. BEGIN
  163. SELECT DISTINCT
  164. RTT.id tranId
  165. ,'transfast' processId
  166. ,RTT.createdDate txnDate
  167. ,AU.userName userName
  168. ,ISNULL(am.parentId,0) partnerId
  169. ,ISNULL(cm.customerId,0) customerId
  170. ,isFirstTran 'Y'
  171. ,'' sfirstName
  172. ,'' smiddleName
  173. ,'' slastName1
  174. ,'' slastName2
  175. ,CM.fullName sfullName
  176. ,CM.idIssueDate sissuedDate
  177. ,CM.idExpiryDate svalidDate
  178. ,CM.dob sdob
  179. ,TST.email semail
  180. ,CASE WHEN SCC.CITY_CODE = '113179' THEN '113071'
  181. ELSE SCC.CITY_CODE END scity
  182. ,CASE WHEN SSC.STATE_CODE = 'JP037' THEN 'JP036'
  183. ELSE SSC.STATE_CODE END sstate
  184. --,SSC.STATE_CODE sstate
  185. ,CM.zipCode szipCode
  186. ,SNCC.countryCode snativeCountry
  187. ,CASE CM.idType
  188. WHEN 'Business Registation' THEN 'BZ'
  189. WHEN 'DRIVERS LICENSE' THEN 'DL'
  190. WHEN 'National ID' THEN 'G2'
  191. WHEN 'PASSPORT' THEN 'PA'
  192. WHEN 'Tohon' THEN 'BZ'
  193. ELSE 'PA'
  194. END sidType --- map idtype name and code with transfast sender idtype value
  195. ,CM.idNumber sidNumber
  196. ,REPLACE(CM.mobile,'+','') smobile
  197. ,CASE
  198. WHEN CM.customerType='4700'
  199. THEN 1
  200. ELSE 0 END IsIndividual
  201. ,ISNULL(CM.address,CM.city) saddress
  202. ,ISNULL(cm.occupation,0) occupationId
  203. ,ISNULL(OCU.detailTitle,0) occupationName
  204. ,'JP' sCountry
  205. --------- receiver details
  206. ,ISNULL(TRT.id,0) receiverId
  207. ,TRT.firstName rfirstName
  208. ,TRT.middleName rmiddleName
  209. ,TRT.lastName1 rlastName1
  210. ,TRT.firstName
  211. +ISNULL(' ' +TRT.middleName,'')
  212. +ISNULL(' '+TRT.lastName1,'')
  213. +ISNULL(' '+TRT.lastName2,'')
  214. rfullName
  215. ,CASE RCON.countryCode
  216. WHEN 'LK' THEN --------- for sri lanka
  217. CASE TRT.idType
  218. WHEN 'Driver License' THEN '188'
  219. WHEN 'Business Registation' THEN '189'
  220. WHEN 'National ID' THEN '195'
  221. WHEN 'Passport' THEN '197'
  222. ELSE '195'
  223. END
  224. WHEN 'ID' THEN -- indonesia
  225. CASE TRT.idType
  226. WHEN 'Driver License' THEN '286'
  227. WHEN 'Passport' THEN '287'
  228. WHEN 'National ID' THEN '288'
  229. ELSE '287'
  230. END
  231. WHEN 'PH' THEN -- PHILIPPINES
  232. CASE TRT.idType
  233. WHEN 'Tohon' THEN '307'
  234. WHEN 'Driver License' THEN '310'
  235. WHEN 'Passport' THEN '316'
  236. WHEN 'Alien Registration Card' THEN '326'
  237. ELSE '316'
  238. END
  239. WHEN 'PK' THEN --- pakistan
  240. CASE TRT.idType
  241. WHEN 'Passport' THEN '270'
  242. WHEN 'Business Registation' THEN '272'
  243. WHEN 'Driver License' THEN '269'
  244. WHEN 'National ID' THEN '271'
  245. ELSE '270'
  246. END
  247. WHEN 'BD' THEN --- bangladesh
  248. CASE TRT.idType
  249. WHEN 'Passport' THEN '12'
  250. WHEN 'National ID' THEN '13'
  251. WHEN 'Driver License' THEN '14'
  252. WHEN 'Business Registation' THEN '16'
  253. ELSE '430'
  254. END
  255. WHEN 'IN' THEN --- india
  256. CASE TRT.idType
  257. WHEN 'Passport' THEN '136'
  258. WHEN 'Business Registation' THEN '137'
  259. WHEN 'Alien Registration Card' THEN '140'
  260. WHEN 'Driver License' THEN '142'
  261. WHEN 'National ID' THEN '329'
  262. ELSE '136'
  263. END
  264. END
  265. ridType --- map with transfast receiver idtype id code
  266. ,TRT.idNumber ridNumber
  267. ,TRT.validDate rvalidDate
  268. ,TRT.dob rdob
  269. ,TRT.homePhone rhomePhone
  270. ,TRT.mobile rmobile
  271. ,RNC.countryCode rnativeCountry
  272. ,ISNULL(TRT.city,TRT.address) rcity
  273. ,TRT.address raddress
  274. ,TRT.email remail
  275. ,raccountNo = CASE WHEN RTT.paymentMethod = 'Bank Deposit' THEN RTT.accountNo ELSE '' END
  276. ,RCON.countryCode rcountry
  277. ,'' branchId
  278. --,CASE RTT.paymentMethod
  279. -- WHEN 'Bank Deposit' THEN APBL.BRANCH_CODE
  280. -- WHEN 'Cash Payment' THEN ABBL.BRANCH_CODE1 END branchId -------- Need To Map With Transfast PayingBranchId
  281. ,CASE RTT.paymentMethod
  282. WHEN 'Bank Deposit' THEN PBD.PAYER_CODE
  283. WHEN 'Cash Payment' THEN ABL.BANK_CODE1 END payerId -------- Need To Map With Transfast PayerId
  284. ,TRT.branchName branchName
  285. ,AU.city city
  286. ,ISNULL(RTT.pAgent,0) pAgent
  287. ,RTT.pAgentName pAgentName
  288. ,RTT.pBankType pBankType
  289. ,CASE RTT.paymentMethod
  290. WHEN 'Bank Deposit' THEN ISNULL(ABL.BANK_CODE1,'')
  291. ELSE '' END pBank
  292. ,ISNULL(abl.BANK_CODE2,0) pBankLocation
  293. ,CASE RTT.paymentMethod
  294. WHEN 'Bank Deposit' THEN ISNULL(ABBL.BRANCH_CODE1,'')
  295. ELSE '' END pBankBranchId
  296. ,RTT.pBankName pBankName
  297. ,RTT.payoutCurr payoutCurr
  298. ,RTT.collCurr collCurr
  299. ,ISNULL(RTT.cAmt,0) cAmt
  300. ,ISNULL(RTT.pAmt,0) pAmt
  301. ,ISNULL(RTT.tAmt,0) tAmt
  302. ,serviceCharge serviceCharge
  303. ,ISNULL(RTT.pAgentComm,0) pAgentComm
  304. ,CASE RCON.countryCode
  305. WHEN 'LK' THEN
  306. CASE RTT.purposeOfRemit
  307. WHEN 'Family maintenance' THEN '1'
  308. WHEN 'Educational expenses' THEN '2'
  309. WHEN 'Medical Expenses' THEN '3'
  310. WHEN 'Business travel' THEN '7'
  311. WHEN 'Trading' THEN '14'
  312. WHEN 'Savings' THEN '18'
  313. WHEN 'Purchase of land / property' THEN '23'
  314. WHEN 'Utility payment' THEN '24'
  315. WHEN 'Rent' THEN '25'
  316. WHEN 'Personal travels and tours' THEN '26'
  317. WHEN 'Trading' THEN '27'
  318. WHEN 'Salary / Commission' THEN '29'
  319. WHEN 'Loan payment / Interest' THEN '30'
  320. ELSE '1'
  321. END
  322. WHEN 'ID' THEN
  323. CASE RTT.purposeOfRemit
  324. WHEN 'Family maintenance' THEN '1'
  325. WHEN 'Educational expenses' THEN '2'
  326. WHEN 'Medical Expenses' THEN '3'
  327. WHEN 'Purchase of land / property' THEN '9'
  328. WHEN 'Trading' THEN '14'
  329. WHEN 'Savings' THEN '18'
  330. WHEN 'Utility payment' THEN '24'
  331. WHEN 'Personal travels and tours' THEN '26'
  332. WHEN 'Loan payment / Interest' THEN '30'
  333. ELSE '1'
  334. END
  335. WHEN 'PH' THEN
  336. CASE RTT.purposeOfRemit
  337. WHEN 'Family maintenance' THEN '1'
  338. WHEN 'Educational expenses' THEN '2'
  339. WHEN 'Medical Expenses' THEN '3'
  340. WHEN 'Business travel' THEN '7'
  341. WHEN 'Trading' THEN '14'
  342. WHEN 'Savings' THEN '18'
  343. WHEN 'Purchase of land / property' THEN '23'
  344. WHEN 'Utility payment' THEN '24'
  345. WHEN 'Personal travels and tours' THEN '26'
  346. WHEN 'Trading' THEN '27'
  347. WHEN 'Salary / Commission' THEN '29'
  348. WHEN 'Loan payment / Interest' THEN '30'
  349. ELSE '1'
  350. END
  351. WHEN 'PK' THEN
  352. CASE RTT.purposeOfRemit
  353. WHEN 'Family maintenance' THEN '1'
  354. WHEN 'Educational expenses' THEN '2'
  355. WHEN 'Medical Expenses' THEN '3'
  356. WHEN 'Trading' THEN '14'
  357. WHEN 'Savings' THEN '18'
  358. WHEN 'Purchase of land / property' THEN '23'
  359. WHEN 'Utility payment' THEN '24'
  360. WHEN 'Personal travels and tours' THEN '26'
  361. WHEN 'Loan payment / Interest' THEN '30'
  362. ELSE '1'
  363. END
  364. WHEN 'BD' THEN
  365. CASE RTT.purposeOfRemit
  366. WHEN 'Family maintenance' THEN '1'
  367. WHEN 'Educational expenses' THEN '2'
  368. WHEN 'Medical Expenses' THEN '3'
  369. WHEN 'Purchase of land / property' THEN '9'
  370. WHEN 'Trading' THEN '14'
  371. WHEN 'Savings' THEN '18'
  372. WHEN 'Utility payment' THEN '24'
  373. WHEN 'Personal travels and tours' THEN '26'
  374. WHEN 'Loan payment / Interest' THEN '30'
  375. ELSE '1'
  376. END
  377. WHEN 'IN' THEN
  378. CASE RTT.purposeOfRemit
  379. WHEN 'Family maintenance' THEN '1'
  380. WHEN 'Savings' THEN '18'
  381. WHEN 'Purchase of land / property' THEN '23'
  382. WHEN 'Educational expenses' THEN '24'
  383. WHEN 'Rent' THEN '25'
  384. WHEN 'Personal travels and tours' THEN '26'
  385. WHEN 'Trading' THEN '27'
  386. WHEN 'Utility payment' THEN '28'
  387. WHEN 'Salary / Commission' THEN '29'
  388. WHEN 'Loan payment / Interest' THEN '30'
  389. WHEN 'Medical Expenses' THEN '32'
  390. ELSE '1'
  391. END
  392. END purposeOfRemit ----------- Map With Transfast code
  393. ,CASE RTT.sourceOfFund
  394. WHEN 'Own business' THEN '1'
  395. WHEN 'Business' THEN '2'
  396. WHEN 'Salary / Wages' THEN '3'
  397. WHEN 'Return from Investment' THEN '4'
  398. WHEN 'Loan from bank' THEN '5'
  399. WHEN 'Lottery' THEN '6'
  400. WHEN 'Part time job' THEN '7'
  401. WHEN 'Pension' THEN '8'
  402. WHEN 'Savings or accumulated' THEN '10'
  403. ELSE '9'
  404. END sourceOfFund
  405. ,rel.detailTitle relationName
  406. ,cm.remarks remarks
  407. ,ISNULL(RTT.sAgent,0) sAgent
  408. ,RTT.sAgentName sAgentName
  409. ,ISNULL(RTT.sSuperAgent,0) sSuperAgent
  410. ,cm.ipAddress ipAddress
  411. ,AU.countryId countryId
  412. ,RSC.STATE_CODE rstate ----- Receiver State Code
  413. ,ISNULL(RTT.sBranch,0) sBranch
  414. ,RTT.pLocation pLocation
  415. ,CASE RTT.paymentMethod
  416. WHEN 'Bank Deposit' THEN 'C'
  417. WHEN 'Cash Payment' THEN '2'
  418. END paymentMethod -------- map with transfast payoutmethod id
  419. ,dbo.decryptDb(RTT.controlNo) controlNo
  420. ,RCC.CITY_CODE rcityCode ----- Receiver City Code
  421. ,RTC.TOWN_CODE rTownCode ----- Receiver Town Code
  422. ,cm.sessionId sessionId
  423. ,'true' IsRealtime
  424. ,bankAccountNo = CASE WHEN RTT.paymentMethod = 'Bank Deposit' THEN RTT.accountNo ELSE '' END
  425. ,'CA' formOfPaymentId
  426. ,CM.SSNNO ssnno
  427. ,RTT.customerrate Rate
  428. ,'N' IsRealtime
  429. FROM remitTran RTT WITH(NOLOCK)
  430. INNER JOIN dbo.tranSenders TST(NOLOCK) ON TST.TRANID = RTT.ID
  431. INNER JOIN customerMaster CM(NOLOCK) ON CM.customerId = TST.customerId
  432. INNER JOIN dbo.tranReceivers TRT(NOLOCK) ON TRT.TRANID = RTT.id
  433. LEFT JOIN applicationUsers AU(NOLOCK) ON AU.USERNAME = RTT.CREATEDBY
  434. LEFT JOIN dbo.agentMaster AM(NOLOCK) ON AM.agentId=RTT.pAgent
  435. LEFT JOIN API_BANK_LIST ABL (NOLOCK) ON ABL.BANK_ID=RTT.pBank
  436. LEFT JOIN dbo.API_BANK_BRANCH_LIST ABBL (NOLOCK) ON ABBL.BRANCH_ID=RTT.pBankBranch -- OR ABBL.BRANCH_NAME=RTT.pBankBranchName
  437. LEFT JOIN dbo.staticDataValue OCU (NOLOCK) ON OCU.valueId=cm.occupation
  438. LEFT JOIN dbo.staticDataValue REL (NOLOCK) ON REL.detailTitle=RTT.relWithSender
  439. --LEFT JOIN dbo.staticDataValue IDT (NOLOCK) ON IDT.valueId=TRT.idType
  440. LEFT JOIN dbo.countryStateMaster CSM(NOLOCK) ON CSM.stateId=cm.state
  441. LEFT JOIN dbo.API_CITY_LIST SCC (NOLOCK) ON SCC.CITY_NAME=CM.city
  442. LEFT JOIN dbo.API_STATE_LIST SSC (NOLOCK) ON SSC.STATE_ID=SCC.STATE_ID
  443. LEFT JOIN dbo.API_STATE_LIST RSC (NOLOCK) ON RSC.STATE_NAME=TRT.STATE
  444. LEFT JOIN dbo.API_CITY_LIST RCC (NOLOCK) ON SCC.CITY_NAME=TRT.city
  445. LEFT JOIN dbo.API_TOWN_LIST RTC (NOLOCK) ON RTC.TOWN_ID=RTT.pLocation
  446. LEFT JOIN dbo.countryMaster SNCC (NOLOCK) ON SNCC.countryId=CM.country
  447. LEFT JOIN dbo.countryMaster RCON (NOLOCK) ON RCON.countryName=TRT.country
  448. LEFT JOIN dbo.countryMaster RNC (NOLOCK) ON RNC.countryName=TRT.NativeCountry OR RNC.countryId = TRT.NativeCountry
  449. LEFT JOIN dbo.PAYER_BANK_DETAILS PBD(NOLOCK) ON PBD.PAYER_ID = RTT.PayerId
  450. --LEFT JOIN dbo.API_PAYOUT_LOACTION APL(NOLOCK) ON APL.Id=RTT.PayerId
  451. --LEFT JOIN dbo.API_PAYOUT_BRANCH_LOACTION APBL (NOLOCK) ON APBL.Id=RTT.PayerBranchId
  452. WHERE RTT.id =@tranId
  453. END
  454. IF @PartnerId= '393880' ----- For JME NEPAL
  455. BEGIN
  456. SELECT
  457. RTT.id tranId ----
  458. ,'jmenepal' processId
  459. ,RTT.createdDate txnDate
  460. ,AU.userName userName -- notes -- Filds are use for jme nepal send model
  461. ,ISNULL(AM.parentId,0) partnerId ---- use for to get thirdparty api partner services
  462. ,ISNULL(CM.customerId,0) customerId
  463. ,isFirstTran 'Y' ----
  464. ,'' sfirstName
  465. ,'' smiddleName
  466. ,'' slastName1
  467. ,'' slastName2
  468. ,CM.fullName sfullName --
  469. ,CM.idIssueDate sissuedDate --
  470. ,CM.idExpiryDate svalidDate --
  471. ,CM.dob sdob --
  472. ,'' semail
  473. ,CM.city scity --
  474. ,'' szipCode
  475. ,TST.nativeCountry snativeCountry --
  476. ,CM.idType sidType --
  477. ,CM.idNumber sidNumber --
  478. ,ISNULL(CM.mobile,TST.mobile) smobile --
  479. ,ISNULL(CM.address,CM.city) saddress --
  480. ,0 occupationId
  481. ,ISNULL(OCU.detailTitle,0) occupationName --
  482. --------- receiver details
  483. ,'' receiverId
  484. ,TRT.fullName rfullName --
  485. ,'' rfirstName
  486. ,'' rmiddleName
  487. ,'' rlastName1
  488. ,'' ridType
  489. ,'' ridNumber
  490. ,'' rvalidDate
  491. ,'' rdob
  492. ,'' rhomePhone
  493. ,ISNULL(TRT.mobile, '0') rmobile --
  494. --,RE.countryCode
  495. ,'' rnativeCountry
  496. ,ISNULL(TRT.city,TRT.address) rcity --
  497. ,TRT.address raddress --
  498. ,'' remail
  499. ,raccountNo = CASE WHEN RTT.paymentMethod = 'Bank Deposit' THEN RTT.accountNo ELSE '' END
  500. ,TRT.country rcountry --
  501. ,'' branchId
  502. ,'' branchName
  503. ,'' city
  504. ,0 pAgent
  505. ,'' pAgentName
  506. ,'' pBankType
  507. ,ISNULL(PBID.BANK_CODE1,0) pBank --
  508. ,ISNULL(PBID.BANK_CODE1,'0') pBankLocation --
  509. ,ISNULL(PBID.BANK_NAME,'') pBankBranchName --
  510. ,RTT.pBankName pBankName --
  511. ,RTT.payoutCurr
  512. ,RTT.collCurr
  513. ,ISNULL(RTT.cAmt,0) cAmt --
  514. ,ISNULL(RTT.pAmt,0) pAmt --
  515. ,ISNULL(RTT.tAmt,0) tAmt --
  516. ,RTT.serviceCharge serviceCharge --
  517. ,'' pAgentComm
  518. ,RIGHT(RTT.purposeOfRemit, 50) purposeOfRemit
  519. ,RTT.sourceOfFund sourceOfFund --
  520. ,'' relationId
  521. ,RTT.relwithsender relationName --
  522. ,'' remarks
  523. ,0 sAgent
  524. ,'' sAgentName
  525. ,0 sSuperAgent
  526. ,'' ipAddress
  527. ,0 countryId
  528. ,RTT.sCountry sCountry --
  529. ,'' rstate
  530. ,0 sBranch
  531. ,'' pLocation
  532. ,RTT.paymentMethod paymentMethod --
  533. ,dbo.decryptDb(RTT.controlNo) controlNo --
  534. ,RTT.customerrate exRate
  535. ,'' rcityCode
  536. ,CM.sessionId sessionId ----
  537. ,'true' IsRealtime ----
  538. ,bankAccountNo = CASE WHEN RTT.paymentMethod = 'Bank Deposit' THEN RTT.accountNo ELSE '' END
  539. ,'Y' IsRealtime
  540. ,RTT.pCurrCostRate SettlementDollarRate
  541. FROM remitTran RTT WITH(NOLOCK)
  542. INNER JOIN dbo.tranSenders TST(NOLOCK) ON TST.TRANID = RTT.ID
  543. INNER JOIN customerMaster CM(NOLOCK) ON CM.customerId = TST.customerId
  544. INNER JOIN dbo.tranReceivers TRT(NOLOCK) ON TRT.TRANID = RTT.ID
  545. LEFT JOIN applicationUsers AU(NOLOCK) ON AU.USERNAME = RTT.CREATEDBY
  546. INNER JOIN dbo.agentMaster AM(NOLOCK) ON AM.agentId=RTT.pAgent
  547. LEFT JOIN API_BANK_LIST PBID (NOLOCK) ON PBID.BANK_ID=RTT.pBank
  548. LEFT JOIN dbo.API_BANK_BRANCH_LIST PBBID (NOLOCK) ON PBBID.BRANCH_ID=RTT.pBankBranch
  549. LEFT JOIN dbo.staticDataValue OCU (NOLOCK) ON CM.occupation=OCU.valueId
  550. LEFT JOIN dbo.staticDataValue REL (NOLOCK) ON REL.valueId=CM.relationId
  551. WHERE RTT.id = @tranId
  552. END
  553. IF @PartnerId= '394397' ----- For GME NEPAL
  554. BEGIN
  555. SELECT
  556. RTT.id tranId ----
  557. ,'gmenepal' processId
  558. ,CONVERT(VARCHAR, RTT.createdDate, 110) txnDate
  559. ,AU.userName userName -- notes -- Filds are use for jme nepal send model
  560. ,ISNULL(AM.parentId,0) partnerId ---- use for to get thirdparty api partner services
  561. ,ISNULL(CM.customerId,0) customerId
  562. ,isFirstTran 'Y' ----
  563. ,'' sfirstName
  564. ,'' smiddleName
  565. ,'' slastName1
  566. ,'' slastName2
  567. ,CM.fullName sfullName --
  568. ,TST.address saddress --
  569. ,CM.mobile smobile --
  570. ,tst.city scity --
  571. ,RTT.sCountry sCountry --
  572. ,TST.idType sidType --
  573. ,TST.idNumber sidNumber --
  574. ,TRT.fullName rfullName --
  575. ,TRT.address raddress --
  576. ,TRT.mobile rmobile --
  577. ,ISNULL(TRT.city,TRT.address) rcity --
  578. ,TRT.country rcountry --
  579. ,RTT.sourceOfFund sourceOfFund --
  580. ,RTT.relwithsender relationName --
  581. ,RTT.purposeOfRemit purposeOfRemit --
  582. ,ISNULL(RTT.cAmt,0) cAmt --
  583. ,ISNULL(RTT.pAmt,0) pAmt --
  584. ,ISNULL(RTT.tAmt,0) tAmt --
  585. ,RTT.paymentMethod paymentMethod --
  586. ,RTT.pBankName pBankName --
  587. ,ISNULL(PBID.BANK_CODE1,0) pBank --
  588. ,pBankLocation = CASE WHEN PBID.BANK_CODE1='11006083' THEN PBID.BANK_CODE2 ELSE ISNULL(PBBID.BRANCH_CODE1,'0') END
  589. ,ISNULL(PBBID.BRANCH_NAME,'') pBankBranchName --
  590. ,raccountNo = CASE WHEN RTT.paymentMethod = 'Bank Deposit' THEN RTT.accountNo ELSE '' END
  591. ,CM.idIssueDate sissuedDate --
  592. ,CM.idExpiryDate svalidDate --
  593. ,CM.dob sdob --
  594. ,'' semail
  595. ,'' szipCode
  596. ,CM.nativeCountry snativeCountry --
  597. ,0 occupationId
  598. ,CASE WHEN CM.occupation = '11383' THEN CM.occupationother ELSE ISNULL(OCU.detailTitle,0) END occupationName --
  599. --------- receiver details
  600. ,'' receiverId
  601. ,'' rfirstName
  602. ,'' rmiddleName
  603. ,'' rlastName1
  604. ,'' ridType
  605. ,'' ridNumber
  606. ,'' rvalidDate
  607. ,'' rdob
  608. ,'' rhomePhone
  609. --,RE.countryCode
  610. ,'' rnativeCountry
  611. ,'' remail
  612. ,'' branchId
  613. ,'' branchName
  614. ,'' city
  615. ,0 pAgent
  616. ,'' pAgentName
  617. ,'' pBankType
  618. ,RTT.payoutCurr
  619. ,RTT.collCurr
  620. ,RTT.SERVICECHARGE serviceCharge --
  621. ,'' pAgentComm
  622. ,'' relationId
  623. ,'' remarks
  624. ,0 sAgent
  625. ,'' sAgentName
  626. ,0 sSuperAgent
  627. ,'' ipAddress
  628. ,0 countryId
  629. ,'' rstate
  630. ,0 sBranch
  631. ,'' pLocation
  632. ,dbo.decryptDb(RTT.controlNo) controlNo --
  633. ,0 exRate
  634. ,'' rcityCode
  635. ,CM.sessionId sessionId ----
  636. ,'true' IsRealtime ----
  637. ,bankAccountNo = CASE WHEN RTT.paymentMethod = 'Bank Deposit' THEN RTT.accountNo ELSE '' END
  638. ,'Y' IsRealtime
  639. ,RTT.company exRateConfirmId
  640. ,RTT.pCurrCostRate SettlementDollarRate
  641. FROM remitTran RTT WITH(NOLOCK)
  642. INNER JOIN dbo.tranSenders TST(NOLOCK) ON TST.TRANID = RTT.ID
  643. INNER JOIN customerMaster CM(NOLOCK) ON CM.customerId = TST.customerId
  644. INNER JOIN dbo.tranReceivers TRT(NOLOCK) ON TRT.TRANID = RTT.ID
  645. LEFT JOIN applicationUsers AU(NOLOCK) ON AU.USERNAME = RTT.CREATEDBY
  646. INNER JOIN dbo.agentMaster AM(NOLOCK) ON AM.agentId=RTT.pAgent
  647. LEFT JOIN API_BANK_LIST PBID (NOLOCK) ON PBID.BANK_ID=RTT.pBank
  648. LEFT JOIN dbo.API_BANK_BRANCH_LIST PBBID (NOLOCK) ON PBBID.BRANCH_ID=RTT.pBankBranch
  649. LEFT JOIN dbo.staticDataValue OCU (NOLOCK) ON OCU.valueId=TST.occupation
  650. LEFT JOIN dbo.staticDataValue REL (NOLOCK) ON REL.valueId=CM.relationId
  651. WHERE RTT.id = @tranId
  652. END
  653. IF @PartnerId= '394400' ----- For CELYON
  654. BEGIN
  655. SELECT
  656. RTT.id tranId ----
  657. ,'bankofceylon' processId
  658. ,CONVERT(VARCHAR, RTT.createdDate, 110) txnDate
  659. ,AU.userName userName -- notes -- Filds are use for jme nepal send model
  660. ,ISNULL(AM.parentId,0) partnerId ---- use for to get thirdparty api partner services
  661. ,ISNULL(CM.customerId,0) customerId
  662. ,isFirstTran 'Y' ----
  663. ,'' sfirstName
  664. ,'' smiddleName
  665. ,'' slastName1
  666. ,'' slastName2
  667. ,CASE WHEN LEN(CM.fullName) >70 THEN LEFT(CM.fullName,69) ELSE (CM.fullName) END sfullName --
  668. ,TST.address saddress --
  669. ,CM.mobile smobile --
  670. ,tst.city scity --
  671. ,RTT.sCountry sCountry --
  672. ,TST.idType sidType --
  673. ,TST.idNumber sidNumber --
  674. ,TRT.fullName rfullName --
  675. ,TRT.address raddress --
  676. ,TRT.mobile rmobile --
  677. ,ISNULL(TRT.city,TRT.address) rcity --
  678. ,TRT.country rcountry --
  679. ,RTT.sourceOfFund sourceOfFund --
  680. ,RTT.relwithsender relationName --
  681. ,RTT.purposeOfRemit purposeOfRemit --
  682. ,ISNULL(RTT.cAmt,0) cAmt --
  683. ,ISNULL(RTT.pAmt,0) pAmt --
  684. ,ISNULL(RTT.tAmt,0) tAmt --
  685. ,CASE WHEN RTT.paymentMethod = 'CASH PAYMENT' THEN '00'
  686. WHEN RTT.paymentMethod = 'BANK DEPOSIT' AND RTT.pBank = 2459 THEN '01'
  687. ELSE '02' END paymentMethod
  688. ,RTT.pBankName pBankName --
  689. ,ISNULL(PBID.BANK_CODE1,0) pBank --
  690. ,pBankLocation = ISNULL(BRANCH_CODE1,'001')
  691. ,ISNULL(PBBID.BRANCH_NAME,'Head Office') pBankBranchName --
  692. ,raccountNo = CASE WHEN RTT.paymentMethod = 'Bank Deposit' THEN RTT.accountNo ELSE '' END
  693. ,CM.idIssueDate sissuedDate --
  694. ,CM.idExpiryDate svalidDate --
  695. ,CM.dob sdob --
  696. ,'' semail
  697. ,'' szipCode
  698. ,CM.nativeCountry snativeCountry --
  699. ,0 occupationId
  700. ,CASE WHEN CM.occupation = '11383' THEN CM.occupationother ELSE ISNULL(OCU.detailTitle,0) END occupationName --
  701. --------- receiver details
  702. ,'' receiverId
  703. ,'' rfirstName
  704. ,'' rmiddleName
  705. ,'' rlastName1
  706. ,'' ridType
  707. ,'' ridNumber
  708. ,'' rvalidDate
  709. ,'' rdob
  710. ,'' rhomePhone
  711. --,RE.countryCode
  712. ,'' rnativeCountry
  713. ,'' remail
  714. ,'' branchId
  715. ,'' branchName
  716. ,'' city
  717. ,0 pAgent
  718. ,'' pAgentName
  719. ,'' pBankType
  720. ,RTT.payoutCurr
  721. ,RTT.collCurr
  722. ,RTT.SERVICECHARGE serviceCharge --
  723. ,'' pAgentComm
  724. ,'' relationId
  725. ,'' remarks
  726. ,0 sAgent
  727. ,'' sAgentName
  728. ,0 sSuperAgent
  729. ,'' ipAddress
  730. ,0 countryId
  731. ,'' rstate
  732. ,0 sBranch
  733. ,'' pLocation
  734. ,dbo.decryptDb(RTT.controlNo) controlNo --
  735. ,0 exRate
  736. ,'' rcityCode
  737. ,CM.sessionId sessionId ----
  738. ,'true' IsRealtime ----
  739. ,bankAccountNo = CASE WHEN RTT.paymentMethod = 'Bank Deposit' THEN RTT.accountNo ELSE '' END
  740. --,'Y' IsRealtime
  741. ,RTT.company exRateConfirmId
  742. ,RTT.pCurrCostRate SettlementDollarRate
  743. FROM remitTran RTT WITH(NOLOCK)
  744. INNER JOIN dbo.tranSenders TST(NOLOCK) ON TST.TRANID = RTT.ID
  745. INNER JOIN customerMaster CM(NOLOCK) ON CM.customerId = TST.customerId
  746. INNER JOIN dbo.tranReceivers TRT(NOLOCK) ON TRT.TRANID = RTT.ID
  747. LEFT JOIN applicationUsers AU(NOLOCK) ON AU.USERNAME = RTT.CREATEDBY
  748. INNER JOIN dbo.agentMaster AM(NOLOCK) ON AM.agentId=RTT.pAgent
  749. LEFT JOIN API_BANK_LIST PBID (NOLOCK) ON PBID.BANK_ID=RTT.pBank
  750. LEFT JOIN dbo.API_BANK_BRANCH_LIST PBBID (NOLOCK) ON PBBID.BRANCH_ID=RTT.pBankBranch
  751. LEFT JOIN dbo.staticDataValue OCU (NOLOCK) ON OCU.valueId=TST.occupation
  752. LEFT JOIN dbo.staticDataValue REL (NOLOCK) ON REL.valueId=CM.relationId
  753. WHERE RTT.id = @tranId
  754. END
  755. IF @PartnerId= '394414' ----- BRAC Bank Limited
  756. BEGIN
  757. SELECT
  758. RTT.id tranId ----
  759. ,'bracBank' processId
  760. ,CONVERT(VARCHAR, RTT.createdDate, 110) txnDate
  761. ,AU.userName userName -- notes -- Filds are use for jme nepal send model
  762. ,ISNULL(AM.parentId,0) partnerId ---- use for to get thirdparty api partner services
  763. ,ISNULL(CM.customerId,0) customerId
  764. ,isFirstTran 'Y' ----
  765. ,'' sfirstName
  766. ,'' smiddleName
  767. ,'' slastName1
  768. ,'' slastName2
  769. ,CM.fullName sfullName --
  770. , RTRIM(LTRIM( dbo.fn_StripCharacters(SSC.stateName + ', ' +TST.address , '^a-z, '))) saddress
  771. ,CM.mobile smobile --
  772. ,tst.city scity --
  773. ,RTT.sCountry sCountry --
  774. , CASE CM.idType
  775. WHEN 'DRIVERS LICENSE' THEN 'NIDN'
  776. WHEN 'National ID' THEN 'DRLC'
  777. WHEN 'PASSPORT' THEN 'CCPT'
  778. ELSE ''
  779. END sidType --
  780. ,TST.idNumber sidNumber --
  781. -- ,'TEST TEST' rfullName
  782. ,TRT.fullName rfullName --
  783. ,REPLACE(TRT.address,':',' ') raddress --
  784. ,CASE WHEN LEN(TRT.mobile) =14 AND TRT.mobile like '+880%' and SUBSTRING(TRT.mobile,4,1)=0
  785. THEN (LEFT(TRT.mobile,3)+ RIGHT(TRT.mobile,LEN(TRT.mobile)-4))
  786. WHEN LEN(TRT.mobile) >14 AND TRT.mobile like '+880%' THEN (LEFT(TRT.mobile,3) + SUBSTRING(TRT.mobile,4,10)) ELSE TRT.mobile END As rmobile --
  787. --,'+8801958189284' rmobile
  788. ,ISNULL(TRT.city,TRT.address) rcity --
  789. ,TRT.country rcountry --
  790. ,RTT.sourceOfFund sourceOfFund --
  791. , CASE RTT.relwithsender
  792. WHEN 'Brother/Sister' THEN 'RELA'
  793. WHEN 'Brother/Sister (In Law)' THEN 'RELA'
  794. WHEN 'Cousin' THEN 'RELA'
  795. WHEN 'Father' THEN 'PARE'
  796. WHEN 'Father in law' THEN 'PARE'
  797. WHEN 'Grand Mother/Grand Father' THEN 'PARE'
  798. WHEN 'Mother' THEN 'PARE'
  799. WHEN 'Mother in law' THEN 'PARE'
  800. WHEN 'Nephew/Niece' THEN 'RELA'
  801. WHEN 'Self' THEN 'SELF'
  802. WHEN 'Son/Daughter' THEN 'CHIL'
  803. WHEN 'Son/Daughter (In Law)' THEN 'RELA'
  804. WHEN 'Spouse (Husband or Wife)' THEN 'SPOU'
  805. WHEN 'Friend' THEN 'FREN'
  806. WHEN 'Uncle/Aunt' THEN 'RELA'
  807. ELSE 'OTHR' --Other cAmt --
  808. END relationName --
  809. ,'FAMI' purposeOfRemit --RTT.purposeOfRemit --
  810. ,ISNULL(RTT.cAmt,0) cAmt --
  811. ,ISNULL(RTT.pAmt,0) pAmt --
  812. ,ISNULL(RTT.tAmt,0) tAmt --
  813. ,CASE WHEN RTT.paymentMethod = 'CASH PAYMENT' THEN '03' --Any Where Cash Payment
  814. WHEN RTT.paymentMethod = 'MOBILE WALLET' THEN '05'
  815. WHEN RTT.paymentMethod = 'BANK DEPOSIT' AND RTT.pBank = 2523 THEN '01' --Account Credit to BRAC Bank
  816. WHEN RTT.paymentMethod = 'BANK DEPOSIT' AND RTT.pBank <> 2523 AND PBID.TRANSFER_MODE='RTP' THEN '06' --NPSB payment
  817. ELSE '02' END paymentMethod -- Account Credit to Other Bank
  818. ,RTT.pBankName pBankName
  819. ,ISNULL(PBID.BANK_CODE1,0) pBank --
  820. ,pBankLocation =ISNULL(BRANCH_CODE1,'001')
  821. ,ISNULL(PBBID.BRANCH_NAME,'Head Office') pBankBranchName --
  822. ,raccountNo = CASE WHEN RTT.paymentMethod in ( 'Bank Deposit','MOBILE WALLET') THEN RTT.accountNo ELSE '' END
  823. ,CM.idIssueDate sissuedDate --
  824. ,CM.idExpiryDate svalidDate --
  825. ,REPLACE(CONVERT(CHAR(10),CM.dob, 103), '/', '') sdob --
  826. ,'' semail
  827. ,'' szipCode
  828. ,'JP' snativeCountry
  829. -- ,CT.countrycode snativeCountry -- ISO 2 digit
  830. ,0 occupationId
  831. ,CASE WHEN CM.occupation = '11383' THEN CM.occupationother ELSE ISNULL(OCU.detailTitle,0) END occupationName --
  832. --------- receiver details
  833. ,'' receiverId
  834. ,'' rfirstName
  835. ,'' rmiddleName
  836. ,'' rlastName1
  837. ,'' ridType
  838. ,'' ridNumber
  839. ,'' rvalidDate
  840. ,'' rdob
  841. ,'' rhomePhone
  842. --,RE.countryCode
  843. ,ncm.CountryCode rnativeCountry
  844. ,'' remail
  845. ,'' branchId
  846. ,'' branchName
  847. ,'' city
  848. ,0 pAgent
  849. ,'' pAgentName
  850. ,CASE WHEN RTT.paymentMethod = 'MOBILE WALLET' THEN '1' ELSE '0' END pBankType --1  bKash , 2  Rocket, 3  UPAY
  851. ,RTT.payoutCurr
  852. ,RTT.collCurr
  853. ,RTT.SERVICECHARGE serviceCharge --
  854. ,'' pAgentComm
  855. ,'' relationId
  856. ,'' remarks
  857. ,0 sAgent
  858. ,'' sAgentName
  859. ,0 sSuperAgent
  860. ,'' ipAddress
  861. ,0 countryId
  862. ,ISNULL(ASL.STATE_CODE,'BD-13') rstate
  863. ,0 sBranch
  864. ,'' pLocation
  865. ,dbo.decryptDb(RTT.controlNo) controlNo
  866. ,0 exRate
  867. ,'' rcityCode
  868. ,CM.sessionId sessionId ----
  869. ,'true' IsRealtime ----
  870. ,bankAccountNo = CASE WHEN RTT.paymentMethod in( 'Bank Deposit') THEN RTT.accountNo ELSE '' END
  871. --,'Y' IsRealtime
  872. ,RTT.company exRateConfirmId
  873. ,RTT.pCurrCostRate SettlementDollarRate
  874. FROM remitTran RTT WITH(NOLOCK)
  875. INNER JOIN dbo.tranSenders TST(NOLOCK) ON TST.TRANID = RTT.ID
  876. INNER JOIN customerMaster CM(NOLOCK) ON CM.customerId = TST.customerId
  877. LEFT JOIN countryMaster ct (NOLOCK) ON CM.nativeCountry = ct.countryId
  878. INNER JOIN dbo.tranReceivers TRT(NOLOCK) ON TRT.TRANID = RTT.ID
  879. LEFT JOIN dbo.receiverInformation(NOLOCK) ri ON ri.receiverId = trt.customerId
  880. LEFT JOIN dbo.countryMaster(NOLOCK) ncm ON ri.nativeCountry = ncm.countryId
  881. LEFT JOIN applicationUsers AU(NOLOCK) ON AU.USERNAME = RTT.CREATEDBY
  882. INNER JOIN dbo.agentMaster AM(NOLOCK) ON AM.agentId=RTT.pAgent
  883. LEFT JOIN API_BANK_LIST PBID (NOLOCK) ON PBID.BANK_ID=RTT.pBank
  884. LEFT JOIN dbo.API_BANK_BRANCH_LIST PBBID (NOLOCK) ON PBBID.BRANCH_ID=RTT.pBankBranch
  885. LEFT JOIN dbo.API_STATE_LIST ASL (NOLOCK) ON asl.STATE_ID = RTT.pState
  886. LEFT JOIN dbo.staticDataValue OCU (NOLOCK) ON OCU.valueId=TST.occupation
  887. LEFT JOIN dbo.staticDataValue REL (NOLOCK) ON REL.valueId=CM.relationId
  888. LEFT JOIN dbo.countryStateMaster SSC (NOLOCK) ON SSC.stateId=CM.state
  889. WHERE RTT.id = @tranId
  890. END
  891. IF @PartnerId= '394428' ----- Cebuana
  892. BEGIN
  893. SELECT
  894. RTT.id tranId ----
  895. ,'cebuana' processId
  896. ,CONVERT(VARCHAR, RTT.createdDate, 110) txnDate
  897. ,AU.userName userName -- notes -- Filds are use for jme nepal send model
  898. ,ISNULL(AM.parentId,0) partnerId ---- use for to get thirdparty api partner services
  899. ,ISNULL(CM.customerId,0) customerId
  900. ,isFirstTran 'Y' ----
  901. ,cm.firstName sfirstName
  902. ,cm.middleName smiddleName
  903. ,cm.lastName1 slastName1
  904. ,'' slastName2
  905. ,CM.fullName sfullName --
  906. ,DBO.RemoveNonASCII(ISNULL(CM.address,CM.city)) saddress --
  907. ,CM.mobile smobile --
  908. ,tst.city scity --
  909. ,sCountry='JPN'
  910. --,RTT.sCountry sCountry --
  911. , CM.idType sidType
  912. ,TST.idNumber sidNumber --
  913. -- ,'TEST TEST' rfullName
  914. ,TRT.fullName rfullName --
  915. ,TRT.address raddress --
  916. , REPLACE(TRT.mobile,'+','') rmobile
  917. ,CASE ISNUMERIC( ISNULL(TRT.city,'Philippines')) WHEN 0 THEN 'Philippines' ELSE TRT.city END rcity --
  918. ,rcountry ='PHL'
  919. --,TRT.country rcountry --
  920. ,RTT.sourceOfFund sourceOfFund --
  921. , CASE RTT.relwithsender
  922. WHEN 'Brother/Sister' THEN 'RTR001' -- RTR001 FAMILY
  923. WHEN 'Brother/Sister (In Law)' THEN 'RTR001'
  924. WHEN 'Cousin' THEN 'RTR001'
  925. WHEN 'Father' THEN 'RTR001'
  926. WHEN 'Father in law' THEN 'RTR001'
  927. WHEN 'Grand Mother/Grand Father' THEN 'RTR001'
  928. WHEN 'Mother' THEN 'RTR001'
  929. WHEN 'Mother in law' THEN 'RTR001'
  930. WHEN 'Nephew/Niece' THEN 'RTR001'
  931. WHEN 'Self' THEN 'RTR001'
  932. WHEN 'Son/Daughter' THEN 'RTR001'
  933. WHEN 'Son/Daughter (In Law)' THEN 'RTR001'
  934. WHEN 'Spouse (Husband or Wife)' THEN 'RTR001'
  935. WHEN 'Friend' THEN 'RTR002' -- RTR002 FRIEND
  936. WHEN 'Uncle/Aunt' THEN 'RTR001'
  937. ELSE 'RTR001'
  938. END relationName --
  939. , CASE RTT.purposeOfRemit
  940. WHEN 'Family Support' THEN 'RTP001'
  941. WHEN 'Payment of Import Good' THEN 'RTP004'
  942. WHEN 'Self Saving' THEN 'RTP002'
  943. WHEN 'Tax Refund' THEN 'RTP011'
  944. WHEN 'Gift' THEN 'RTP003'
  945. WHEN 'Donation' THEN 'RTP003'
  946. WHEN 'Gift' THEN 'RTP009'
  947. WHEN 'Loan Payment/Interest' THEN 'RTP007'
  948. ELSE 'RTP012'
  949. END AS purposeOfRemit
  950. ,ISNULL(RTT.cAmt,0) cAmt --
  951. ,ISNULL(RTT.pAmt,0) pAmt --
  952. ,ISNULL(RTT.tAmt,0) tAmt --
  953. --,CASE WHEN RTT.paymentMethod = 'CASH PAYMENT' THEN 'CPU' --Any Where Cash Payment
  954. --WHEN RTT.paymentMethod = 'BANK DEPOSIT' THEN 'RTA'
  955. --END paymentMethod
  956. ,RTT.paymentMethod
  957. ,RTT.pBankName pBankName
  958. ,ISNULL(PBID.BANK_CODE1,0) pBank --
  959. ,pBankLocation =ISNULL(BRANCH_CODE1,'001')
  960. ,ISNULL(PBBID.BRANCH_NAME,'Head Office') pBankBranchName --
  961. , raccountNo = CASE WHEN RTT.paymentMethod in ( 'Bank Deposit','MOBILE WALLET') THEN RTT.accountNo ELSE '' END
  962. ,CM.idIssueDate sissuedDate --
  963. ,CM.idExpiryDate svalidDate --
  964. ,REPLACE(CONVERT(CHAR(10),CM.dob, 103), '/', '') sdob --
  965. ,'' semail
  966. ,cm.zipCode szipCode
  967. ,CT.countryName snativeCountry -- ISO 2 digit
  968. ,0 occupationId
  969. ,CASE WHEN CM.occupation = '11383' THEN CM.occupationother ELSE ISNULL(OCU.detailTitle,0) END occupationName --
  970. --------- receiver details
  971. ,'' receiverId
  972. ,TRT.firstName rfirstName
  973. ,TRT.middleName rmiddleName
  974. ,TRT.lastName1 rlastName1
  975. ,'' ridType
  976. ,'' ridNumber
  977. ,'' rvalidDate
  978. ,'' rdob
  979. ,'' rhomePhone
  980. --,RE.countryCode
  981. ,ncm.countryName rnativeCountry
  982. ,'' remail
  983. ,'' branchId
  984. ,'' branchName
  985. ,'' city
  986. ,0 pAgent
  987. ,'' pAgentName
  988. ,0 pBankType
  989. ,RTT.payoutCurr
  990. ,RTT.collCurr
  991. ,RTT.SERVICECHARGE serviceCharge --
  992. ,'' pAgentComm
  993. ,'' relationId
  994. ,'' remarks
  995. ,0 sAgent
  996. ,'' sAgentName
  997. ,0 sSuperAgent
  998. ,'' ipAddress
  999. ,0 countryId
  1000. ,ASL.STATE_NAME rstate
  1001. ,0 sBranch
  1002. ,'' pLocation
  1003. ,dbo.decryptDb(RTT.controlNo)controlNo
  1004. ,0 exRate
  1005. ,CASE LEN(ISNULL(ACL.CITY_CODE,'')) WHEN 3 THEN ACL.CITY_CODE ELSE '6525' END rcityCode
  1006. ,CM.sessionId sessionId ----
  1007. ,'true' IsRealtime ----
  1008. ,bankAccountNo = CASE WHEN RTT.paymentMethod in( 'Bank Deposit') THEN RTT.accountNo ELSE '' END
  1009. --,'Y' IsRealtime
  1010. ,RTT.company exRateConfirmId
  1011. ,RTT.pCurrCostRate SettlementDollarRate
  1012. ,cm.city SState
  1013. FROM remitTran RTT WITH(NOLOCK)
  1014. INNER JOIN dbo.tranSenders TST(NOLOCK) ON TST.TRANID = RTT.ID
  1015. INNER JOIN customerMaster CM(NOLOCK) ON CM.customerId = TST.customerId
  1016. LEFT JOIN countryMaster ct (NOLOCK) ON CM.nativeCountry = ct.countryId
  1017. INNER JOIN dbo.tranReceivers TRT(NOLOCK) ON TRT.TRANID = RTT.ID
  1018. LEFT JOIN dbo.receiverInformation(NOLOCK) ri ON ri.receiverId = trt.customerId
  1019. LEFT JOIN dbo.countryMaster(NOLOCK) ncm ON ri.nativeCountry = ncm.countryId
  1020. LEFT JOIN applicationUsers AU(NOLOCK) ON AU.USERNAME = RTT.CREATEDBY
  1021. INNER JOIN dbo.agentMaster AM(NOLOCK) ON AM.agentId=RTT.pAgent
  1022. LEFT JOIN API_BANK_LIST PBID (NOLOCK) ON PBID.BANK_ID=RTT.pBank
  1023. LEFT JOIN dbo.API_BANK_BRANCH_LIST PBBID (NOLOCK) ON PBBID.BRANCH_ID=RTT.pBankBranch
  1024. LEFT JOIN dbo.API_STATE_LIST ASL (NOLOCK) ON asl.STATE_ID = RTT.pState
  1025. LEFT JOIN dbo.staticDataValue OCU (NOLOCK) ON OCU.valueId=TST.occupation
  1026. LEFT JOIN dbo.staticDataValue REL (NOLOCK) ON REL.valueId=CM.relationId
  1027. LEFT JOIN dbo.API_CITY_LIST acl (NOLOCK) ON acl.CITY_ID = RTT.pDistrict
  1028. --LEFT JOIN dbo.API_CITY_LIST SCC (NOLOCK) ON SCC.CITY_NAME=CM.city
  1029. --LEFT JOIN dbo.API_STATE_LIST SSC (NOLOCK) ON SSC.STATE_ID=SCC.STATE_ID
  1030. WHERE RTT.id = @tranId
  1031. END
  1032. END TRY
  1033. BEGIN CATCH
  1034. IF @@TRANCOUNT > 0
  1035. ROLLBACK TRANSACTION
  1036. SELECT 1 error_code, ERROR_MESSAGE() mes, NULL id
  1037. END CATCH
  1038. END