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.

496 lines
12 KiB

1 year ago
  1. USE [FastMoneyPro_Remit]
  2. GO
  3. /****** Object: StoredProcedure [dbo].[proc_online_temp_to_main] Script Date: 7/4/2019 11:35:48 AM ******/
  4. DROP PROCEDURE [dbo].[proc_online_temp_to_main]
  5. GO
  6. /****** Object: StoredProcedure [dbo].[proc_online_temp_to_main] Script Date: 7/4/2019 11:35:48 AM ******/
  7. SET ANSI_NULLS ON
  8. GO
  9. SET QUOTED_IDENTIFIER ON
  10. GO
  11. CREATE PROC [dbo].[proc_online_temp_to_main]
  12. @id BIGINT ouTPUT
  13. ,@voucherDetails xml = null
  14. AS
  15. SET XACT_ABORT ON;
  16. SET NOCOUNT ON;
  17. BEGIN Transaction
  18. declare @tranId bigint
  19. INSERT INTO remitTranTemp(
  20. [controlNo]
  21. ,[sCurrCostRate]
  22. ,[sCurrHoMargin]
  23. ,[sCurrSuperAgentMargin]
  24. ,[sCurrAgentMargin]
  25. ,[pCurrCostRate]
  26. ,[pCurrHoMargin]
  27. ,[pCurrSuperAgentMargin]
  28. ,[pCurrAgentMargin]
  29. ,[agentCrossSettRate]
  30. ,[customerRate]
  31. ,[sAgentSettRate]
  32. ,[pDateCostRate]
  33. ,[agentFxGain]
  34. ,[treasuryTolerance]
  35. ,[customerPremium]
  36. ,[schemePremium]
  37. ,[sharingValue]
  38. ,[sharingType]
  39. ,[serviceCharge]
  40. ,[handlingFee]
  41. ,[sAgentComm]
  42. ,[sAgentCommCurrency]
  43. ,[sSuperAgentComm]
  44. ,[sSuperAgentCommCurrency]
  45. ,[pAgentComm]
  46. ,[pAgentCommCurrency]
  47. ,[pSuperAgentComm]
  48. ,[pSuperAgentCommCurrency]
  49. ,[promotionCode]
  50. ,[promotionType]
  51. ,[pMessage]
  52. ,[sCountry]
  53. ,[sSuperAgent]
  54. ,[sSuperAgentName]
  55. ,[sAgent]
  56. ,[sAgentName]
  57. ,[sBranch]
  58. ,[sBranchName]
  59. ,[pCountry]
  60. ,[pSuperAgent]
  61. ,[pSuperAgentName]
  62. ,[pAgent]
  63. ,[pAgentName]
  64. ,[pBranch]
  65. ,[pBranchName]
  66. ,[paymentMethod]
  67. ,[pBank]
  68. ,[pBankName]
  69. ,[pBankBranch]
  70. ,[pBankBranchName]
  71. ,[accountNo]
  72. ,[externalBankCode]
  73. ,[collMode]
  74. ,[collCurr]
  75. ,[tAmt]
  76. ,[cAmt]
  77. ,[pAmt]
  78. ,[payoutCurr]
  79. ,[relWithSender]
  80. ,[purposeOfRemit]
  81. ,[sourceOfFund]
  82. ,[tranStatus]
  83. ,[payStatus]
  84. ,[createdDate]
  85. ,[createdDateLocal]
  86. ,[createdBy]
  87. ,[modifiedDate]
  88. ,[modifiedDateLocal]
  89. ,[modifiedBy]
  90. ,[approvedDate]
  91. ,[approvedDateLocal]
  92. ,[approvedBy]
  93. ,[paidDate]
  94. ,[paidDateLocal]
  95. ,[paidBy]
  96. ,[cancelRequestDate]
  97. ,[cancelRequestDateLocal]
  98. ,[cancelRequestBy]
  99. ,[cancelReason]
  100. ,[refund]
  101. ,[cancelCharge]
  102. ,[cancelApprovedDate]
  103. ,[cancelApprovedDateLocal]
  104. ,[cancelApprovedBy]
  105. ,[blockedDate]
  106. ,[blockedBy]
  107. ,[lockedDate]
  108. ,[lockedDateLocal]
  109. ,[lockedBy]
  110. ,[payTokenId]
  111. ,[sendEOD]
  112. ,[payEOD]
  113. ,[cancelEOD]
  114. ,[tranType]
  115. ,[ContNo]
  116. ,[uploadLogId]
  117. ,[company]
  118. ,[voucherNo]
  119. ,[controlNo2]
  120. ,[pBankType]
  121. ,[expectedPayoutAgent]
  122. ,[routedBy]
  123. ,[routedDate]
  124. ,[senderName]
  125. ,[receiverName]
  126. ,[trnStatusBeforeCnlReq]
  127. ,[schemeId]
  128. ,[lockStatus]
  129. ,[isOnlineTxn]
  130. ,pState,pDistrict, sRouteId
  131. )
  132. SELECT
  133. controlNo
  134. ,[sCurrCostRate]
  135. ,[sCurrHoMargin]
  136. ,[sCurrSuperAgentMargin]
  137. ,[sCurrAgentMargin]
  138. ,[pCurrCostRate]
  139. ,[pCurrHoMargin]
  140. ,[pCurrSuperAgentMargin]
  141. ,[pCurrAgentMargin]
  142. ,[agentCrossSettRate]
  143. ,[customerRate]
  144. ,[sAgentSettRate]
  145. ,[pDateCostRate]
  146. ,[agentFxGain]
  147. ,[treasuryTolerance]
  148. ,[customerPremium]
  149. ,[schemePremium]
  150. ,[sharingValue]
  151. ,[sharingType]
  152. ,[serviceCharge]
  153. ,[handlingFee]
  154. ,[sAgentComm]
  155. ,[sAgentCommCurrency]
  156. ,[sSuperAgentComm]
  157. ,[sSuperAgentCommCurrency]
  158. ,[pAgentComm]
  159. ,[pAgentCommCurrency]
  160. ,[pSuperAgentComm]
  161. ,[pSuperAgentCommCurrency]
  162. ,[promotionCode]
  163. ,[promotionType]
  164. ,[pMessage]
  165. ,[sCountry]
  166. ,[sSuperAgent]
  167. ,[sSuperAgentName]
  168. ,[sAgent]
  169. ,[sAgentName]
  170. ,[sBranch]
  171. ,[sBranchName]
  172. ,[pCountry]
  173. ,[pSuperAgent]
  174. ,[pSuperAgentName]
  175. ,[pAgent]
  176. ,[pAgentName]
  177. ,[pBranch]
  178. ,[pBranchName]
  179. ,[paymentMethod]
  180. ,[pBank]
  181. ,[pBankName]
  182. ,[pBankBranch]
  183. ,[pBankBranchName]
  184. ,[accountNo]
  185. ,[externalBankCode]
  186. ,[collMode]
  187. ,[collCurr]
  188. ,[tAmt]
  189. ,[cAmt]
  190. ,[pAmt]
  191. ,[payoutCurr]
  192. ,[relWithSender]
  193. ,[purposeOfRemit]
  194. ,[sourceOfFund]
  195. --,CASE WHEN @customerStatus ='PendingUser' THEN 'Hold' ELSE 'Payment' END
  196. ,[transtatus]
  197. ,[payStatus]
  198. ,[createdDate]
  199. ,[createdDateLocal]
  200. ,[createdBy]
  201. ,[modifiedDate]
  202. ,[modifiedDateLocal]
  203. ,[modifiedBy]
  204. ,[approvedDate]--CASE WHEN @customerStatus ='PendingUser' THEN null ELSE DBO.FNADateFormatTZ(GETDATE(), 'admin') END --[approvedDate]
  205. ,[approvedDateLocal]--CASE WHEN @customerStatus ='PendingUser' THEN null ELSE GETDATE() END --[approvedDateLocal]
  206. ,[approvedBy]--CASE WHEN @customerStatus ='PendingUser' THEN null ELSE @txnUser END --[approvedBy]
  207. ,[paidDate]
  208. ,[paidDateLocal]
  209. ,[paidBy]
  210. ,[cancelRequestDate]
  211. ,[cancelRequestDateLocal]
  212. ,[cancelRequestBy]
  213. ,[cancelReason]
  214. ,[refund]
  215. ,[cancelCharge]
  216. ,[cancelApprovedDate]
  217. ,[cancelApprovedDateLocal]
  218. ,[cancelApprovedBy]
  219. ,[blockedDate]
  220. ,[blockedBy]
  221. ,[lockedDate]
  222. ,[lockedDateLocal]
  223. ,[lockedBy]
  224. ,[payTokenId]
  225. ,[sendEOD]
  226. ,[payEOD]
  227. ,[cancelEOD]
  228. ,[tranType]
  229. ,[ContNo]
  230. ,[id]
  231. ,[company]
  232. ,[voucherNo]
  233. ,[controlNo2]
  234. ,[pBankType]
  235. ,[expectedPayoutAgent]
  236. ,[routedBy]
  237. ,[routedDate]
  238. ,[senderName]
  239. ,[receiverName]
  240. ,[trnStatusBeforeCnlReq]
  241. ,[schemeId]
  242. ,[lockStatus]
  243. ,[isOnlineTxn]
  244. ,pState,pDistrict, sRouteId
  245. FROM remitTranTempOnline WITH (NOLOCK)
  246. WHERE id = @id
  247. SET @tranId = @@IDENTITY
  248. INSERT INTO [tranSendersTemp](
  249. [tranId]
  250. ,[customerId]
  251. ,[membershipId]
  252. ,[firstName]
  253. ,[middleName]
  254. ,[lastName1]
  255. ,[lastName2]
  256. ,[fullName]
  257. ,[country]
  258. ,[address]
  259. ,[state]
  260. ,[district]
  261. ,[zipCode]
  262. ,[city]
  263. ,[email]
  264. ,[homePhone]
  265. ,[workPhone]
  266. ,[mobile]
  267. ,[nativeCountry]
  268. ,[dob]
  269. ,[placeOfIssue]
  270. ,[customerType]
  271. ,[occupation]
  272. ,[idType]
  273. ,[idNumber]
  274. ,[idPlaceOfIssue]
  275. ,[issuedDate]
  276. ,[validDate]
  277. ,[extCustomerId]
  278. ,[cwPwd]
  279. ,[ttName]
  280. ,[isFirstTran]
  281. ,[customerRiskPoint]
  282. ,[countryRiskPoint]
  283. ,[gender]
  284. ,[salary]
  285. ,[companyName]
  286. ,[address2]
  287. ,[dcInfo]
  288. ,[ipAddress]
  289. ,[notifySms]
  290. ,[txnTestQuestion]
  291. ,[txnTestAnswer]
  292. )
  293. SELECT
  294. @tranId
  295. ,[customerId]
  296. ,[membershipId]
  297. ,[firstName]
  298. ,[middleName]
  299. ,[lastName1]
  300. ,[lastName2]
  301. ,[fullName]
  302. ,[country]
  303. ,[address]
  304. ,[state]
  305. ,[district]
  306. ,[zipCode]
  307. ,[city]
  308. ,[email]
  309. ,[homePhone]
  310. ,[workPhone]
  311. ,[mobile]
  312. ,[nativeCountry]
  313. ,[dob]
  314. ,[placeOfIssue]
  315. ,[customerType]
  316. ,[occupation]
  317. ,[idType]
  318. ,[idNumber]
  319. ,[idPlaceOfIssue]
  320. ,[issuedDate]
  321. ,[validDate]
  322. ,[extCustomerId]
  323. ,[cwPwd]
  324. ,[ttName]
  325. ,[isFirstTran]
  326. ,[customerRiskPoint]
  327. ,[countryRiskPoint]
  328. ,[gender]
  329. ,[salary]
  330. ,[companyName]
  331. ,[address2]
  332. ,[dcInfo]
  333. ,[ipAddress]
  334. ,[notifySms]
  335. ,[txnTestQuestion]
  336. ,[txnTestAnswer]
  337. FROM [tranSendersTempOnline] WITH (NOLOCK) WHERE tranId = @id
  338. INSERT INTO [tranReceiversTemp](
  339. [tranId]
  340. ,[customerId]
  341. ,[membershipId]
  342. ,[firstName]
  343. ,[middleName]
  344. ,[lastName1]
  345. ,[lastName2]
  346. ,[fullName]
  347. ,[country]
  348. ,[address]
  349. ,[state]
  350. ,[district]
  351. ,[zipCode]
  352. ,[city]
  353. ,[email]
  354. ,[homePhone]
  355. ,[workPhone]
  356. ,[mobile]
  357. ,[nativeCountry]
  358. ,[dob]
  359. ,[placeOfIssue]
  360. ,[customerType]
  361. ,[occupation]
  362. ,[idType]
  363. ,[idNumber]
  364. ,[idPlaceOfIssue]
  365. ,[issuedDate]
  366. ,[validDate]
  367. ,[idType2]
  368. ,[idNumber2]
  369. ,[idPlaceOfIssue2]
  370. ,[issuedDate2]
  371. ,[validDate2]
  372. ,[relationType]
  373. ,[relativeName]
  374. ,[gender]
  375. ,[address2]
  376. ,[dcInfo]
  377. ,[ipAddress]
  378. )
  379. SELECT
  380. @tranId
  381. ,[customerId]
  382. ,[membershipId]
  383. ,[firstName]
  384. ,[middleName]
  385. ,[lastName1]
  386. ,[lastName2]
  387. ,[fullName]
  388. ,[country]
  389. ,[address]
  390. ,[state]
  391. ,[district]
  392. ,[zipCode]
  393. ,[city]
  394. ,[email]
  395. ,[homePhone]
  396. ,[workPhone]
  397. ,[mobile]
  398. ,[nativeCountry]
  399. ,[dob]
  400. ,[placeOfIssue]
  401. ,[customerType]
  402. ,[occupation]
  403. ,[idType]
  404. ,[idNumber]
  405. ,[idPlaceOfIssue]
  406. ,[issuedDate]
  407. ,[validDate]
  408. ,[idType2]
  409. ,[idNumber2]
  410. ,[idPlaceOfIssue2]
  411. ,[issuedDate2]
  412. ,[validDate2]
  413. ,[relationType]
  414. ,[relativeName]
  415. ,[gender]
  416. ,[address2]
  417. ,[dcInfo]
  418. ,[ipAddress]
  419. FROM [tranReceiversTempOnline] WITH (NOLOCK)
  420. WHERE tranId = @id
  421. INSERT INTO collectionDetails(
  422. tranId
  423. ,collMode
  424. ,countryBankId
  425. ,amt
  426. ,collDate
  427. ,narration
  428. ,branchId
  429. ,createdBy
  430. ,createdDate)
  431. SELECT
  432. @tranId
  433. ,collMode
  434. ,countryBankId
  435. ,amt
  436. ,collDate
  437. ,narration
  438. ,branchId
  439. ,createdBy
  440. ,createdDate
  441. FROM collectionDetailsOnline
  442. WHERE tranId = @id
  443. INSERT INTO customerTxnHistory
  444. (
  445. Tranno,refno
  446. ,senderFax,senderPassport
  447. ,SenderName,sender_mobile,SenderAddress,SenderCountry,customerId,membershipId
  448. ,receiverIDDescription,receiverID
  449. ,receiverName,ReceiverPhone,receiver_mobile,ReceiverAddress,ReceiverCity,ReceiverCountry
  450. ,rBankACNo,rBankName,rBankBranch,rBankID
  451. ,ben_bank_id,ben_bank_name,rBankAcType
  452. ,receiveAgentID,expected_payoutagentid,paymentType
  453. ,paidAmt
  454. ,confirmDate
  455. ,paidCType,receiveCType
  456. ,pAgent,pAgentName,pBranch,pBranchName
  457. ,pBank,pBankName,pBankBranch,pBankBranchName
  458. )
  459. SELECT
  460. rt.id,rt.controlNo
  461. ,ts.idType,ts.idNumber
  462. ,ts.fullName,ts.mobile,ts.address,ts.companyName,ts.customerId,ts.membershipId
  463. ,tv.idType,tv.idNumber
  464. ,tv.fullName,tv.homePhone,tv.mobile,tv.address,tv.city,pCountry
  465. ,rt.accountNo,pAgentName,pBranchName,pBranch
  466. ,NULL,pBankName,pBankBranchName
  467. ,pAgent,pAgent,paymentMethod
  468. ,cAmt
  469. ,NULL
  470. ,collCurr,payoutCurr
  471. ,pAgent,pAgentName,pBranch,pBranchName
  472. ,pBank,pBankName,pBankBranch,pBankBranchName
  473. FROM vwRemitTran rt WITH(NOLOCK) --customers
  474. INNER JOIN vwTranSenders ts WITH(NOLOCK) ON rt.id=ts.tranId
  475. INNER JOIN vwTranReceivers tv WITH(NOLOCK) ON rt.id=tv.tranId
  476. --INNER JOIN customers cus WITH(NOLOCK) ON ts.customerId = cus.customerId
  477. where rt.id = @tranId
  478. DELETE FROM remitTranTempOnline where id = @id
  479. DELETE FROM tranSendersTempOnline where tranId = @id
  480. DELETE FROM tranReceiversTempOnline where tranId = @id
  481. SET @id = @tranId
  482. COMMIT TRANSACTION
  483. GO