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.

1648 lines
117 KiB

10 months ago
9 months ago
10 months ago
10 months ago
10 months ago
9 months ago
10 months ago
9 months ago
9 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
10 months ago
10 months ago
  1. USE [FastMoneyPro_Remit]
  2. GO
  3. /****** Object: StoredProcedure [dbo].[proc_modifyTXN] Script Date: 12/14/2023 4:27:16 PM ******/
  4. SET ANSI_NULLS ON
  5. GO
  6. SET QUOTED_IDENTIFIER ON
  7. GO
  8. ALTER PROC [dbo].[proc_modifyTXN]
  9. @flag VARCHAR(50) = NULL
  10. ,@user VARCHAR(30) = NULL
  11. ,@tranId INT = NULL
  12. ,@rowId INT = NULL
  13. ,@fieldName VARCHAR(200) = NULL
  14. ,@oldValue VARCHAR(200) = NULL
  15. ,@newTxtValue VARCHAR(200) = NULL
  16. ,@newDdlValue VARCHAR(200) = NULL
  17. ,@firstName VARCHAR(200) = NULL
  18. ,@middleName VARCHAR(200) = NULL
  19. ,@lastName1 VARCHAR(200) = NULL
  20. ,@lastName2 VARCHAR(200) = NULL
  21. ,@contactNo VARCHAR(200) = NULL
  22. ,@bankNewName INT = NULL
  23. ,@branchNewName VARCHAR(100) = NULL
  24. ,@isAPI CHAR(1) = NULL
  25. ,@fieldValue VARCHAR(200) = NULL
  26. ,@branchId VARCHAR(50) = NULL
  27. ,@emailId VARCHAR(200) = NULL
  28. ,@sessionId NVARCHAR(MAX) = NULL
  29. ,@pCountryId INT = NULL
  30. AS
  31. SET NOCOUNT ON
  32. SET XACT_ABORT ON
  33. BEGIN TRY
  34. CREATE TABLE #msg(errorCode INT, msg VARCHAR(100), id INT)
  35. DECLARE
  36. @xml XML
  37. ,@pDistrict VARCHAR(100)
  38. ,@pDistrictId INT
  39. ,@pState VARCHAR(100)
  40. ,@pStateId INT
  41. ,@controlNo VARCHAR(30)
  42. ,@message VARCHAR(500)
  43. ,@agentRefId VARCHAR(15)
  44. ,@controlNoEncrypted VARCHAR(30)
  45. ,@tranNo BIGINT
  46. ,@deliveryMethodId INT
  47. ,@deliveryMethod VARCHAR(50)
  48. ,@sBranch INT
  49. ,@pSuperAgent INT
  50. ,@sCountryId INT
  51. ,@sCountry VARCHAR(100)
  52. --,@pCountryId INT
  53. ,@pCountry VARCHAR(100)
  54. ,@pLocation INT
  55. ,@agentId INT
  56. ,@amount MONEY
  57. ,@oldSc MONEY
  58. ,@newSc MONEY
  59. ,@collCurr VARCHAR(3)
  60. ,@senderName VARCHAR(200)
  61. ,@receiverName VARCHAR(200)
  62. ,@senderOfacRes VARCHAR(MAX)
  63. ,@receiverOfacRes VARCHAR(MAX)
  64. ,@ofacRes VARCHAR(MAX)
  65. ,@ofacReason VARCHAR(200)
  66. ,@nepDate VARCHAR(50)
  67. DECLARE
  68. @parentId INT
  69. ,@branchName VARCHAR(200)
  70. ,@agentName VARCHAR(200)
  71. ,@locationCode INT
  72. ,@locationName VARCHAR(200)
  73. ,@oldLocation VARCHAR(200)
  74. ,@oldAgentId INT
  75. ,@oldAgentName VARCHAR(200)
  76. ,@supAgentId INT
  77. ,@supAgentName VARCHAR(200)
  78. ,@payStatus VARCHAR(50)
  79. ,@MAXID INT
  80. ,@MINID INT
  81. ,@modifyId INT
  82. ,@tranType CHAR(1)
  83. ,@receiverId INT
  84. ,@customerId INT
  85. ,@pBankType CHAR(1)
  86. SET @agentRefId = '1' + LEFT(CAST(ABS(CHECKSUM(NEWID())) AS VARCHAR(10)) + '000000000', 8)
  87. SET @nepDate = dbo.FNAGetDateInNepalTZ()
  88. SELECT @tranId = id from remittran where holdtranid = @tranId
  89. SELECT
  90. @controlNo = dbo.FNADecryptString(controlNo)
  91. ,@pCountry = pCountry
  92. ,@controlNoEncrypted = controlNo
  93. ,@payStatus = payStatus
  94. ,@receiverId = trt.customerid
  95. ,@customerId = tst.customerid
  96. FROM remitTran rtt
  97. INNER JOIN tranreceivers trt on trt.tranid = rtt.id
  98. INNER JOIN transenders tst on tst.tranid = rtt.id
  99. WHERE rtt.id = @tranId
  100. -- ## Direct Modification
  101. IF @flag='u'
  102. BEGIN
  103. DECLARE @pSuperAgentTemp int
  104. SELECT @pSuperAgentTemp=pSuperAgent FROM REMITTRANTEMP WHERE id = @tranId
  105. SELECT @pSuperAgent=pSuperAgent FROM REMITTRAN WHERE id = @tranId
  106. IF isnull(@pSuperAgentTemp,@pSuperAgent) = '394130'
  107. BEGIN
  108. EXEC proc_errorHandler 1,'Sorry you cannot modify Transfast transaction.Please contact HQ!',@tranId
  109. RETURN;
  110. END
  111. DECLARE @memId VARCHAR(50)
  112. --IF @payStatus = 'Post'
  113. --BEGIN
  114. -- SET @message = 'Transaction not authorised for modification; Status:'+@payStatus;
  115. -- EXEC proc_errorHandler 1, @message, @tranId
  116. -- RETURN;
  117. --END
  118. SELECT @memId = membershipId FROM tranSenders (NOLOCK) WHERE tranId = @tranId
  119. IF @fieldName='senderName'
  120. BEGIN
  121. IF @firstName IS NULL
  122. BEGIN
  123. EXEC proc_errorHandler 1, 'Please enter valid first name!', @tranId
  124. RETURN
  125. END
  126. IF EXISTS(SELECT 'X' FROM customerMaster WITH(NOLOCK) WHERE membershipId = @memId)
  127. BEGIN
  128. EXEC proc_errorHandler 1, 'You can not modify this transaction made by membered customer.', @tranId
  129. RETURN
  130. END
  131. SELECT @firstName = UPPER(@firstName), @middleName = UPPER(@middleName), @lastName1 = UPPER(@lastName1), @lastName2 = UPPER(@lastName2)
  132. SET @senderName = ISNULL(@firstName, '') + ISNULL(' ' + @middleName, '') + ISNULL(' ' + @lastName1, '') + ISNULL(' ' +@lastName2, '')
  133. SELECT @tranType = tranType FROM remitTran (NOLOCK) WHERE id = @tranId
  134. BEGIN TRANSACTION
  135. UPDATE tranSenders SET
  136. firstName = @firstName
  137. ,middleName = @middleName
  138. ,lastName1 = @lastName1
  139. ,lastName2 = @lastName2
  140. ,fullName = @senderName
  141. WHERE tranId = @tranId
  142. UPDATE remitTran SET senderName = @senderName WHERE id = @tranId
  143. UPDATE customerTxnHistory SET senderName = @senderName WHERE refNo = dbo.encryptdb(@controlNo)
  144. SET @message = 'Sender Name:'+ ISNULL(@oldValue, '') + ' has been changed to ' + @senderName
  145. INSERT INTO tranModifyLog (tranId,message,createdBy,createdDate,MsgType, status)
  146. SELECT @tranId, @message, @user,@nepDate,'MODIFY', 'APPROVED'
  147. --## update accounting db
  148. UPDATE FastMoneyPro_account.dbo.remit_trn_master SET SENDER_NAME = @senderName WHERE trn_ref_no = dbo.encryptdb(@controlNo)
  149. COMMIT TRANSACTION
  150. EXEC proc_ofacTracker @flag = 't', @name = @senderName, @Result = @senderOfacRes OUTPUT
  151. END
  152. ELSE IF @fieldName = 'sIdType'
  153. BEGIN
  154. IF @newDdlValue IS NULL
  155. BEGIN
  156. EXEC proc_errorHandler 1, 'Please enter valid id type!', @tranId
  157. RETURN
  158. END
  159. IF EXISTS(SELECT 'X' FROM customerMaster WITH(NOLOCK) WHERE membershipId = @memId)
  160. BEGIN
  161. EXEC proc_errorHandler 1, 'You can not modify this transaction made by membered customer.', @tranId
  162. RETURN
  163. END
  164. BEGIN TRAN
  165. UPDATE tranSenders SET
  166. idType = @newDdlValue
  167. WHERE tranId = @tranId
  168. SET @message = 'Sender Id Type:' + ISNULL(@oldValue, '') + ' has been changed to ' + ISNULL(@newDdlValue, '')
  169. INSERT INTO tranModifyLog(tranId,message,createdBy,createdDate,MsgType, status)
  170. SELECT @tranId,@message,@user,@nepDate,'MODIFY' , 'APPROVED'
  171. COMMIT TRAN
  172. END
  173. ELSE IF @fieldName = 'sIdNo'
  174. BEGIN
  175. IF @newTxtValue IS NULL
  176. BEGIN
  177. EXEC proc_errorHandler 1, 'Please enter valid id number!', @tranId
  178. RETURN
  179. END
  180. IF EXISTS(SELECT 'X' FROM customerMaster WITH(NOLOCK) WHERE membershipId = @memId)
  181. BEGIN
  182. EXEC proc_errorHandler 1, 'You can not modify this transaction made by membered customer.', @tranId
  183. RETURN
  184. END
  185. BEGIN TRAN
  186. UPDATE tranSenders SET
  187. idNumber = @newTxtValue
  188. WHERE tranId = @tranId
  189. SET @message = 'Sender ID No:' + isnull(@oldValue, '') + ' has been changed to ' + ISNULL(@newTxtValue, '')
  190. INSERT INTO tranModifyLog(tranId,message,createdBy,createdDate,MsgType, status)
  191. SELECT @tranId,@message,@user,@nepDate,'MODIFY', 'APPROVED'
  192. COMMIT TRAN
  193. END
  194. ELSE IF @fieldName = 'sAddress'
  195. BEGIN
  196. IF @newTxtValue IS NULL
  197. BEGIN
  198. EXEC proc_errorHandler 1, 'Please enter valid address!', @tranId
  199. RETURN
  200. END
  201. IF EXISTS(SELECT 'X' FROM customerMaster WITH(NOLOCK) WHERE membershipId = @memId)
  202. BEGIN
  203. EXEC proc_errorHandler 1, 'You can not modify this transaction made by membered customer.', @tranId
  204. RETURN
  205. END
  206. BEGIN TRAN
  207. UPDATE tranSenders SET
  208. address = @newTxtValue
  209. WHERE tranId = @tranId
  210. SET @message = 'Sender Address:' + ISNULL(@oldValue,'') + ' has been changed to ' + ISNULL(@newTxtValue, '')
  211. INSERT INTO tranModifyLog(tranId,message,createdBy,createdDate,MsgType, status)
  212. SELECT @tranId,@message,@user,@nepDate,'MODIFY', 'APPROVED'
  213. COMMIT TRAN
  214. END
  215. ELSE IF @fieldName = 'sContactNo'
  216. BEGIN
  217. IF @contactNo IS NULL
  218. BEGIN
  219. EXEC proc_errorHandler 1, 'Please enter valid contact number!', @tranId
  220. RETURN
  221. END
  222. IF EXISTS(SELECT 'X' FROM customerMaster WITH(NOLOCK) WHERE membershipId = @memId)
  223. BEGIN
  224. EXEC proc_errorHandler 1, 'You can not modify this transaction made by membered customer.', @tranId
  225. RETURN
  226. END
  227. BEGIN TRAN
  228. UPDATE tranSenders SET
  229. mobile = @contactNo
  230. WHERE tranId = @tranId
  231. SET @message = 'Sender Contact No:' + ISNULL(@oldValue,'') + ' has been changed to ' + ISNULL(@contactNo,'')
  232. INSERT INTO tranModifyLog(tranId,MESSAGE,createdBy,createdDate,MsgType, status)
  233. SELECT @tranId,@message,@user,@nepDate,'MODIFY' , 'APPROVED'
  234. COMMIT TRAN
  235. END
  236. ELSE IF @fieldName = 'receiverName'
  237. BEGIN
  238. IF @firstName IS NULL
  239. BEGIN
  240. EXEC proc_errorHandler 1, 'Please enter valid first name!' , @tranId
  241. RETURN
  242. END
  243. IF @lastName1 IS NULL
  244. BEGIN
  245. EXEC proc_errorHandler 1, 'Please enter valid last name!', @tranId
  246. RETURN
  247. END
  248. SELECT @firstName = UPPER(@firstName), @middleName = UPPER(@middleName), @lastName1 = UPPER(@lastName1), @lastName2 = UPPER(@lastName2)
  249. SET @receiverName = ISNULL(@firstName, '') + ISNULL(' ' + @middleName, '') + ISNULL(' ' + @lastName1, '') + ISNULL(' ' + @lastName2, '')
  250. SELECT @tranType = tranType FROM remitTran (NOLOCK) WHERE id = @tranId
  251. EXEC PROC_RECEIVERMODIFYLOGS @FLAG = 'i-fromModificationNew'
  252. ,@user = @user
  253. ,@receiverId = @receiverId
  254. ,@customerId = @customerId
  255. ,@tranId = @tranId
  256. ,@firstName = @firstName
  257. ,@middleName = @middleName
  258. ,@lastName1 = @lastName1
  259. ,@lastName2 = @lastName2
  260. ,@nameChanged = 1
  261. ,@isNotXmlData = 1
  262. ,@sessionId = @sessionId
  263. BEGIN TRAN
  264. --alerdy done in PROC_RECEIVERMODIFYLOGS
  265. --UPDATE tranReceivers SET firstName = @firstName
  266. -- ,middleName = @middleName
  267. -- ,lastName1 = @lastName1
  268. -- ,lastName2 = @lastName2
  269. -- ,fullName = @receiverName
  270. --WHERE tranId = @tranId
  271. UPDATE remitTran SET receiverName = @receiverName WHERE id = @tranId
  272. UPDATE customerTxnHistory SET receiverName = @receiverName WHERE tranNo = @tranId
  273. SET @message = 'Receiver Name:' + ISNULL(@oldValue, '') + ' has been changed to ' + @receiverName
  274. INSERT INTO tranModifyLog(tranId,message,createdBy,createdDate,MsgType, status)
  275. SELECT @tranId,@message,@user,@nepDate,'MODIFY', 'APPROVED'
  276. UPDATE FastMoneyPro_account.dbo.remit_trn_master SET Receiver_Name = @receiverName WHERE trn_ref_no = dbo.encryptdb(@controlNo)
  277. --## update accounting db
  278. COMMIT TRAN
  279. EXEC proc_ofacTracker @flag = 't', @name = @receiverName, @Result = @receiverOfacRes OUTPUT
  280. END
  281. ELSE IF @fieldName = 'rAddress'
  282. BEGIN
  283. IF @newTxtValue is null
  284. BEGIN
  285. EXEC proc_errorHandler 1, 'Please enter valid address!', @tranId
  286. RETURN
  287. END
  288. EXEC PROC_RECEIVERMODIFYLOGS @FLAG = 'i-fromModificationNew'
  289. ,@user = @user
  290. ,@receiverId = @receiverId
  291. ,@customerId = @customerId
  292. ,@address = @newTxtValue
  293. ,@tranId = @tranId
  294. ,@sessionId = @sessionId
  295. BEGIN TRAN
  296. UPDATE tranReceivers SET address = @newTxtValue WHERE tranId = @tranId
  297. UPDATE receiverInformation SET address = @newTxtValue WHERE receiverId = @receiverId
  298. SET @message = 'Receiver Address:'+ isnull(@oldValue,'')+' has been changed to '+isnull(@newTxtValue,'')
  299. INSERT INTO tranModifyLog(tranId,message,createdBy,createdDate,MsgType, status)
  300. SELECT @tranId, @message, @user, @nepDate, 'MODIFY' , 'APPROVED'
  301. COMMIT TRAN
  302. END
  303. ELSE IF @fieldName = 'rIdType'
  304. BEGIN
  305. IF @newDdlValue IS NULL
  306. BEGIN
  307. EXEC proc_errorHandler 1, 'Please enter valid id type!', @tranId
  308. RETURN
  309. END
  310. EXEC PROC_RECEIVERMODIFYLOGS @FLAG = 'i-fromModificationNew'
  311. ,@user = @user
  312. ,@receiverId = @receiverId
  313. ,@customerId = @customerId
  314. ,@idType = @newDdlValue
  315. ,@tranId = @tranId
  316. ,@sessionId = @sessionId
  317. BEGIN TRAN
  318. UPDATE tranReceivers SET idType = @newDdlValue WHERE tranId = @tranId
  319. UPDATE receiverInformation SET idType = @newDdlValue WHERE receiverId = @receiverId
  320. SET @message = 'Receiver Id Type:' + ISNULL(@oldValue, '') + ' has been changed to ' + ISNULL(@newDdlValue, '')
  321. INSERT INTO tranModifyLog(tranId,message,createdBy,createdDate,MsgType, status)
  322. SELECT @tranId,@message,@user,@nepDate,'MODIFY' , 'APPROVED'
  323. COMMIT TRAN
  324. END
  325. ELSE IF @fieldName = 'rTelNo'
  326. BEGIN
  327. IF @contactNo IS NULL
  328. BEGIN
  329. EXEC proc_errorHandler 1, 'Please enter valid telephone number!', @tranId
  330. RETURN
  331. END
  332. BEGIN TRAN
  333. UPDATE tranSenders SET
  334. homephone = @contactNo
  335. WHERE tranId = @tranId
  336. SET @message = 'Sender telephone number:'+ isnull(@oldValue,'')+' has been changed to '+isnull(@contactNo,'')
  337. INSERT INTO tranModifyLog(tranId,message,createdBy,createdDate,MsgType, status)
  338. SELECT @tranId,@message,@user,@nepDate,'MODIFY', 'APPROVED'
  339. COMMIT TRAN
  340. END
  341. ELSE IF @fieldName = 'rContactNo'
  342. BEGIN
  343. IF @contactNo is null
  344. BEGIN
  345. EXEC proc_errorHandler 1, 'Please enter valid contact number!', @tranId
  346. RETURN
  347. END
  348. EXEC PROC_RECEIVERMODIFYLOGS @FLAG = 'i-fromModificationNew'
  349. ,@user = @user
  350. ,@receiverId = @receiverId
  351. ,@customerId = @customerId
  352. ,@mobile = @contactNo
  353. ,@tranId = @tranId
  354. ,@sessionId = @sessionId
  355. BEGIN TRAN
  356. UPDATE tranReceivers SET mobile = @contactNo WHERE tranId = @tranId
  357. UPDATE receiverInformation SET mobile = @contactNo WHERE receiverId = @receiverId
  358. SET @message = 'Receiver Contact No:'+ isnull(@oldValue,'')+' has been changed to '+isnull(@contactNo,'')
  359. INSERT INTO tranModifyLog(tranId,message,createdBy,createdDate,MsgType, status)
  360. SELECT @tranId,@message,@user,@nepDate,'MODIFY' , 'APPROVED'
  361. COMMIT TRAN
  362. END
  363. ELSE IF @fieldName = 'relationship'
  364. BEGIN
  365. IF @newDdlValue IS NULL
  366. BEGIN
  367. EXEC proc_errorHandler 1, 'Please enter valid Receiver relationship with sender!', @tranId
  368. RETURN
  369. END
  370. BEGIN TRAN
  371. UPDATE remitTran SET
  372. relWithSender = @newDdlValue
  373. WHERE id = @tranId
  374. SET @message = 'Receiver relationship with sender :'+ ISNULL(@oldValue,'')+' has been changed to '+ISNULL(@newDdlValue,'')
  375. INSERT INTO tranModifyLog(tranId,MESSAGE,createdBy,createdDate,MsgType, status)
  376. SELECT @tranId,@message,@user,@nepDate,'MODIFY' , 'APPROVED'
  377. COMMIT TRAN
  378. END
  379. ELSE IF @fieldName = 'rIdNo'
  380. BEGIN
  381. IF @newTxtValue is null
  382. BEGIN
  383. EXEC proc_errorHandler 1, 'Please enter valid id number!', @tranId
  384. RETURN
  385. END
  386. EXEC PROC_RECEIVERMODIFYLOGS @FLAG = 'i-fromModificationNew'
  387. ,@user = @user
  388. ,@receiverId = @receiverId
  389. ,@customerId = @customerId
  390. ,@idNumber = @newTxtValue
  391. ,@tranId = @tranId
  392. ,@sessionId = @sessionId
  393. BEGIN TRAN
  394. UPDATE tranReceivers SET idNumber = @newTxtValue WHERE tranId = @tranId
  395. UPDATE receiverInformation SET idNumber = @newTxtValue WHERE receiverId = @receiverId
  396. SET @message = 'Receiver ID No:'+ isnull(@oldValue,'')+' has been changed to '+isnull(@newTxtValue,'')
  397. INSERT INTO tranModifyLog(tranId,message,createdBy,createdDate,MsgType, status)
  398. SELECT @tranId,@message,@user,@nepDate,'MODIFY' , 'APPROVED'
  399. COMMIT TRAN
  400. END
  401. ----###SMS for Trouble Ticket----
  402. DECLARE
  403. @msg VARCHAR(MAX)
  404. ,@mobileNo VARCHAR(100)
  405. ,@country VARCHAr(100)
  406. IF @message IS NOT NULL AND @mobileNo IS NOT NULL
  407. BEGIN
  408. SET @msg= 'Dear Customer, '+@message+' '+'Please confirm the detail and visit sending agent,if modification required.'
  409. --mobile no check
  410. SELECT @mobileNo=ts.mobile,@country=ts.country
  411. FROM RemitTran rt
  412. INNER JOIN tranSenders ts on rt.controlNo=dbo.FNAEncryptString(@controlNo)
  413. WHERE ts.mobile IS NOT NULL
  414. EXEC sp_InsertIntoSMSQueue 'sms' ,@user ,@msg,@country,NULL,@agentId ,@branchId ,@mobileNo ,@controlNo ,@tranId
  415. END
  416. ELSE IF @fieldName = 'txnTestQuestion'
  417. BEGIN
  418. IF @newTxtValue is null
  419. BEGIN
  420. EXEC proc_errorHandler 1, 'Please enter valid id number!', @tranId
  421. RETURN
  422. END
  423. BEGIN TRAN
  424. UPDATE tranSenders SET
  425. txnTestQuestion = @newTxtValue
  426. WHERE tranId = @tranId
  427. SET @message = 'Test Question:'+ isnull(@oldValue,'')+' has been changed to '+isnull(@newTxtValue,'')
  428. INSERT INTO tranModifyLog(tranId,message,createdBy,createdDate,MsgType, status)
  429. SELECT @tranId,@message,@user,@nepDate,'MODIFY' , 'APPROVED'
  430. COMMIT TRAN
  431. END
  432. ELSE IF @fieldName = 'txnTestAnswer'
  433. BEGIN
  434. IF @newTxtValue is null
  435. BEGIN
  436. EXEC proc_errorHandler 1, 'Please enter valid id number!', @tranId
  437. RETURN
  438. END
  439. BEGIN TRAN
  440. UPDATE tranSenders SET
  441. txnTestAnswer = @newTxtValue
  442. WHERE tranId = @tranId
  443. SET @message = 'Test Answer:'+ isnull(@oldValue,'')+' has been changed to '+isnull(@newTxtValue,'')
  444. INSERT INTO tranModifyLog(tranId,message,createdBy,createdDate,MsgType, status)
  445. SELECT @tranId,@message,@user,@nepDate,'MODIFY' , 'APPROVED'
  446. COMMIT TRAN
  447. END
  448. ELSE IF @fieldName = 'accountNo'
  449. BEGIN
  450. IF @newDdlValue IS NULL
  451. BEGIN
  452. EXEC proc_errorHandler 1, 'Please enter valid account number!', @tranId
  453. RETURN
  454. END
  455. SELECT @tranType = tranType FROM remitTran (NOLOCK) WHERE id = @tranId
  456. EXEC PROC_RECEIVERMODIFYLOGS @FLAG = 'i-fromModificationNew'
  457. ,@user = @user
  458. ,@receiverId = @receiverId
  459. ,@customerId = @customerId
  460. ,@receiverAccountNo = @newDdlValue
  461. ,@tranId = @tranId
  462. ,@sessionId = @sessionId
  463. BEGIN TRAN
  464. UPDATE remitTran SET accountNo = @newDdlValue WHERE id = @tranId
  465. UPDATE receiverInformation SET receiverAccountNo = @newDdlValue WHERE receiverId = @receiverId
  466. SET @message = 'Account Number:'+ ISNULL(@oldValue,'')+' has been changed to '+ISNULL(@newDdlValue,'')
  467. INSERT INTO tranModifyLog(tranId,MESSAGE,createdBy,createdDate,MsgType, status)
  468. SELECT @tranId,@message,@user,@nepDate,'MODIFY' , 'APPROVED'
  469. IF @tranType = 'I'
  470. UPDATE FastMoneyPro_account.dbo.remit_trn_master SET customerId = @newDdlValue WHERE trn_ref_no = dbo.encryptdb(@controlNo)
  471. COMMIT TRAN
  472. END
  473. ELSE IF @fieldName = 'BankName'
  474. BEGIN
  475. IF @bankNewName is null
  476. BEGIN
  477. EXEC proc_errorHandler 1, 'Please enter valid bank name!', @tranId
  478. RETURN
  479. END
  480. DECLARE @payOutPartnerId BIGINT, @pBankId BIGINT, @bankName VARCHAR(200), @bankBranchName VARCHAR(200)
  481. SELECT @payOutPartnerId = AGENTID
  482. FROM TblPartnerwiseCountry(NOLOCK)
  483. WHERE CountryId = @pCountryId
  484. AND IsActive = 1
  485. AND IsMobileEnabled = 1
  486. IF EXISTS (
  487. SELECT *
  488. FROM API_BANK_LIST_MASTER(NOLOCK)
  489. WHERE MASTER_BANK_ID = @bankNewName
  490. AND IS_ACTIVE = '1'
  491. )
  492. BEGIN
  493. SELECT @pBankId = AB.BANK_ID
  494. FROM API_BANK_LIST AB(NOLOCK)
  495. INNER JOIN API_BANK_LIST_MASTER ABM(NOLOCK) ON AB.JME_BANK_CODE = ABM.JME_BANK_CODE
  496. WHERE MASTER_BANK_ID = @bankNewName
  497. AND ABM.IS_ACTIVE = '1'
  498. AND AB.API_PARTNER_ID = @payOutPartnerId
  499. END
  500. SELECT @bankName = dbo.GetBankNameFromId(@bankNewName)
  501. SELECT @bankBranchName = dbo.GetBranchName(@branchNewName)
  502. BEGIN TRAN
  503. IF @pCountryId <> 151
  504. BEGIN
  505. IF @branchNewName is null
  506. BEGIN
  507. EXEC proc_errorHandler 1, 'Please enter valid bank name!', @tranId
  508. RETURN
  509. END
  510. IF EXISTS(SELECT 'X' FROM remitTranTemp WHERE id = @tranId)
  511. BEGIN
  512. UPDATE remitTranTemp SET pBank = @pBankId,
  513. pBankName = @bankName
  514. ,pBankBranch = @bankNewName
  515. ,pBankBranchName = @bankBranchName
  516. WHERE id = @tranId
  517. UPDATE RECEIVERINFORMATION SET payoutpartner = @bankNewName
  518. ,banklocation = CASE
  519. WHEN ISNUMERIC(@branchNewName) = 1 THEN @branchNewName
  520. ELSE 0
  521. END
  522. WHERE receiverId = @receiverId
  523. END
  524. ELSE IF EXISTS (SELECT 1 FROM remitTran WHERE id = @tranId)
  525. BEGIN
  526. UPDATE remitTran SET pBank = @pBankId,
  527. pBankName = @bankName
  528. ,pBankBranch = ISNULL(@bankNewName,0)
  529. ,pBankBranchName =ISNULL( @bankBranchName,'HEAD OFFICE')
  530. WHERE id = @tranId
  531. UPDATE RECEIVERINFORMATION SET payoutpartner = @bankNewName
  532. ,banklocation = CASE
  533. WHEN ISNUMERIC(@branchNewName) = 1 THEN @branchNewName
  534. ELSE 0
  535. END
  536. WHERE receiverId = @receiverId
  537. END
  538. END
  539. ELSE
  540. BEGIN
  541. IF EXISTS(SELECT 'X' FROM remitTranTemp WHERE id = @tranId)
  542. BEGIN
  543. UPDATE remitTranTemp SET pBank = @pBankId,
  544. pBankName = @bankName
  545. WHERE id = @tranId
  546. UPDATE RECEIVERINFORMATION SET payoutpartner = @bankNewName
  547. ,banklocation = ISNULL(@branchNewName,'')
  548. WHERE receiverId = @receiverId
  549. END
  550. ELSE IF EXISTS (SELECT 1 FROM remitTran WHERE id = @tranId)
  551. BEGIN
  552. UPDATE remitTran SET pBank = @pBankId,
  553. pBankName=dbo.GetBankNameFromId(@bankNewName)
  554. WHERE id = @tranId
  555. UPDATE RECEIVERINFORMATION SET payoutpartner = @bankNewName
  556. ,banklocation = ISNULL(@branchNewName,'')
  557. WHERE receiverId = @receiverId
  558. END
  559. END
  560. SET @message = 'Bank Name:'+ isnull(@oldValue,'')+' has been changed to '+ @bankName
  561. INSERT INTO tranModifyLog(tranId,message,createdBy,createdDate,MsgType)
  562. SELECT @tranId,@message,@user,@nepDate,'MODIFY'
  563. IF @pCountryId <> 151
  564. BEGIN
  565. DECLARE @message2 VARCHAR(200) = NULL
  566. SET @message2 = 'Branch name has been changed to '+ @bankBranchName
  567. INSERT INTO tranModifyLog(tranId,message,createdBy,createdDate,MsgType)
  568. SELECT @tranId,@message2,@user,@nepDate,'MODIFY'
  569. END
  570. COMMIT TRAN
  571. END
  572. ELSE IF @fieldName = 'BranchName'
  573. BEGIN
  574. EXEC proc_errorHandler 1, 'Feature not available at the moment', @tranId
  575. RETURN
  576. IF @newDdlValue is null
  577. BEGIN
  578. EXEC proc_errorHandler 1, 'Please enter valid branch name!', @tranId
  579. RETURN
  580. END
  581. EXEC PROC_RECEIVERMODIFYLOGS @FLAG = 'i-fromModificationNew'
  582. ,@user = @user
  583. ,@receiverId = @receiverId
  584. ,@customerId = @customerId
  585. ,@bankLocation = @newDdlValue
  586. ,@tranId = @tranId
  587. ,@sessionId = @sessionId
  588. BEGIN TRAN
  589. UPDATE remitTran SET pBankBranch = @newDdlValue
  590. ,pBankBranchName=dbo.GetAgentNameFromId(@newDdlValue)
  591. WHERE id = @tranId
  592. UPDATE RECEIVERINFORMATION SET bankLocation = dbo.GetAgentNameFromId(@newDdlValue)
  593. WHERE receiverId = @receiverId
  594. SET @message = 'Branch Name:'+ isnull(@oldValue,'')+' has been changed to '+isnull(dbo.GetAgentNameFromId(@newDdlValue),'')
  595. INSERT INTO tranModifyLog(tranId,message,createdBy,createdDate,MsgType)
  596. SELECT @tranId,@message,@user,@nepDate,'MODIFY'
  597. COMMIT TRAN
  598. SELECT @pBankType = pBankType FROM remitTran WITH(NOLOCK) WHERE id = @tranId
  599. END
  600. ELSE IF @fieldName = 'pBranchName'
  601. BEGIN
  602. IF @newDdlValue is null
  603. BEGIN
  604. EXEC proc_errorHandler 1, 'Please enter valid branch name!', @tranId
  605. RETURN
  606. END
  607. SELECT @locationCode=agentLocation FROM agentMaster (NOLOCK) WHERE agentId=@newDdlValue
  608. SELECT @locationName=districtName FROM api_districtList (NOLOCK) WHERE districtCode=@locationCode
  609. SELECT @oldAgentId= CASE WHEN ISNULL(pAgent,0)=ISNULL(pBranch,0) THEN pSuperAgent ELSE pAgent END
  610. FROM remitTran (NOLOCK) WHERE id=@tranId
  611. SELECT @oldAgentName=agentName FROM agentMaster (NOLOCK) WHERE agentId=@oldAgentId
  612. IF EXISTS(SELECT actAsBranch from agentMaster (NOLOCK) WHERE agentId=@newDdlValue AND actAsBranch='y')
  613. BEGIN
  614. -- ## branch name
  615. SELECT @branchName=agentName
  616. FROM agentMaster (NOLOCK)
  617. WHERE agentId=@newDdlValue
  618. -- ## super agent
  619. SELECT @supAgentId=parentId
  620. FROM agentMaster (NOLOCK) WHERE agentId=@newDdlValue
  621. SELECT @supAgentName=agentName
  622. FROM agentMaster (NOLOCK) WHERE agentId=@supAgentId
  623. BEGIN TRAN
  624. -- ## update if agent act as a branch
  625. UPDATE remitTran SET
  626. pAgent = @newDdlValue,
  627. pBranch=@newDdlValue,
  628. pAgentName=@branchName,
  629. pBranchName=@branchName,
  630. pSuperAgent=@supAgentId,
  631. pSuperAgentName=@supAgentName
  632. WHERE id = @tranId
  633. -- ## update transaction log
  634. INSERT INTO tranModifyLog(tranId,message,createdBy,createdDate,MsgType, status)
  635. SELECT @tranId,'Branch Name:'+ isnull(@oldValue,'')+' has been changed to '+isnull(@branchName,''),@user,@nepDate,'MODIFY' , 'APPROVED'
  636. INSERT INTO tranModifyLog(tranId,message,createdBy,createdDate,MsgType, status)
  637. SELECT @tranId,'Agent Name:'+ isnull(@oldAgentName,'')+' has been changed to '+isnull(@supAgentName,''),@user,@nepDate,'MODIFY', 'APPROVED'
  638. COMMIT TRAN
  639. END
  640. ELSE
  641. BEGIN
  642. -- ## branch name & agent name
  643. SELECT @parentId=parentId, @branchName=agentName
  644. FROM agentMaster (NOLOCK)
  645. WHERE agentId=@newDdlValue
  646. SELECT @agentName=agentName
  647. FROM agentMaster (NOLOCK)
  648. WHERE agentId=@parentId
  649. -- ## super agent
  650. SELECT @supAgentId=parentId
  651. FROM agentMaster (NOLOCK) WHERE agentId=@parentId
  652. SELECT @supAgentName=agentName
  653. FROM agentMaster (NOLOCK) WHERE agentId=@supAgentId
  654. BEGIN TRAN
  655. -- ## update remitTran
  656. UPDATE remitTran SET
  657. pAgent = @parentId,
  658. pBranch=@newDdlValue,
  659. pAgentName=@agentName,
  660. pBranchName=@branchName,
  661. pSuperAgent=@supAgentId,
  662. pSuperAgentName=@supAgentName
  663. WHERE id = @tranId
  664. -- ## update transaction log
  665. INSERT INTO tranModifyLog(tranId,message,createdBy,createdDate,MsgType, status)
  666. SELECT @tranId,'Branch Name:'+ isnull(@oldValue,'')+' has been changed to '+isnull(@branchName,''),@user,@nepDate,'MODIFY' , 'APPROVED'
  667. INSERT INTO tranModifyLog(tranId,message,createdBy,createdDate,MsgType, status)
  668. SELECT @tranId,'Agent Name:'+ isnull(@oldAgentName,'')+' has been changed to '+isnull(@agentName,''),@user,@nepDate,'MODIFY' , 'APPROVED'
  669. COMMIT TRAN
  670. END
  671. END
  672. ELSE IF @fieldName = 'rCity'
  673. BEGIN
  674. IF @newTxtValue IS NULL
  675. BEGIN
  676. EXEC proc_errorHandler 1, 'Please enter valid receiver city!', @tranId
  677. RETURN
  678. END
  679. BEGIN TRAN
  680. UPDATE tranreceivers SET
  681. city = @newTxtValue
  682. WHERE tranId = @tranId
  683. SET @message = 'Receiver City :'+ ISNULL(@oldValue,'')+' has been changed to '+ISNULL(@newTxtValue,'')
  684. INSERT INTO tranModifyLog(tranId,MESSAGE,createdBy,createdDate,MsgType, status)
  685. SELECT @tranId,@message,@user,@nepDate,'MODIFY' , 'APPROVED'
  686. COMMIT TRAN
  687. END
  688. ELSE IF @fieldName = 'sCity'
  689. BEGIN
  690. IF @newTxtValue IS NULL
  691. BEGIN
  692. EXEC proc_errorHandler 1, 'Please enter valid Sender City!', @tranId
  693. RETURN
  694. END
  695. BEGIN TRAN
  696. UPDATE transenders SET
  697. city = @newTxtValue
  698. WHERE tranId = @tranId
  699. SET @message = 'Sender City :'+ ISNULL(@oldValue,'')+' has been changed to '+ISNULL(@newTxtValue,'')
  700. INSERT INTO tranModifyLog(tranId,MESSAGE,createdBy,createdDate,MsgType, status)
  701. SELECT @tranId,@message,@user,@nepDate,'MODIFY' ,'APPROVED'
  702. COMMIT TRAN
  703. END
  704. ELSE IF @fieldName = 'pAgentLocation'
  705. BEGIN
  706. IF @newDdlValue IS NULL
  707. BEGIN
  708. EXEC proc_errorHandler 1, 'Please enter valid agent payout location!', @tranId
  709. RETURN
  710. END
  711. SELECT
  712. @deliveryMethod = paymentMethod
  713. ,@sBranch = sBranch
  714. ,@pSuperAgent = pSuperAgent
  715. ,@sCountry = sCountry
  716. ,@pCountry = pCountry
  717. ,@agentId = pBranch
  718. ,@amount = tAmt
  719. ,@oldSc = serviceCharge
  720. ,@collCurr = collCurr
  721. ,@controlNo = dbo.FNADecryptString(controlNo)
  722. ,@pLocation = pLocation
  723. FROM remitTran WITH(NOLOCK)
  724. WHERE id = @tranId
  725. /*
  726. IF (@pLocation = 137 AND @newDdlValue <> 137)
  727. BEGIN
  728. EXEC proc_errorHandler 1, 'Service Charge or Commission for this location varies. Cannot modify Location.', @tranId
  729. RETURN
  730. END
  731. IF (@newDdlValue = 137 AND @pLocation <> 137)
  732. BEGIN
  733. EXEC proc_errorHandler 1, 'Service Charge or Commission for this location varies. Cannot modify Location.', @tranId
  734. RETURN
  735. END
  736. */
  737. SELECT @deliveryMethodId = serviceTypeId FROM serviceTypeMaster WITH(NOLOCK) WHERE typeTitle = @deliveryMethod AND ISNULL(isDeleted, 'N') = 'N'
  738. SELECT @sCountryId = countryId FROM countryMaster WITH(NOLOCK) WHERE countryName = @sCountry
  739. SELECT @pCountryId = countryId FROM countryMaster WITH(NOLOCK) WHERE countryName = @pCountry
  740. IF(@sCountry = 'Nepal')
  741. SELECT @newSc = ISNULL(serviceCharge, 0) FROM dbo.FNAGetDomesticSendComm(@sBranch, NULL, @newDdlValue, @deliveryMethodId, @amount)
  742. ELSE
  743. SELECT @newSc = ISNULL(amount, -1) FROM [dbo].FNAGetSC(@sBranch, @pSuperAgent, @pCountryId, @newDdlValue, @agentId , @deliveryMethodId, @amount, @collCurr)
  744. SELECT @pDistrictId = districtId FROM apiLocationMapping WITH(NOLOCK) WHERE apiDistrictCode = @newDdlValue
  745. SELECT @pDistrict = districtName, @pStateId = zone FROM zoneDistrictMap WITH(NOLOCK) WHERE districtId = @pDistrictId
  746. SELECT @pState = stateName FROM countryStateMaster WITH(NOLOCK) WHERE stateId = @pStateId
  747. BEGIN TRAN
  748. UPDATE remitTran SET
  749. pLocation = @newDdlValue
  750. ,pDistrict = @pDistrict
  751. ,pState = @pState
  752. WHERE id = @tranId
  753. SELECT @message = 'Agent Payout Location :' + ISNULL(@oldValue,'') + ' has been changed to ' + ISNULL(districtName, '') FROM api_districtList WHERE districtCode = @newDdlValue
  754. INSERT INTO tranModifyLog(tranId,message,createdBy,createdDate,MsgType)
  755. SELECT @tranId,@message,@user,dbo.FNAGetDateInNepalTZ(),'M'
  756. COMMIT TRAN
  757. END
  758. ELSE IF @fieldName = 'paymentMethod'
  759. BEGIN
  760. DECLARE @paymentMode VARCHAR(200)
  761. SELECT @paymentMode = typeTitle FROM serviceTypeMaster WHERE serviceTypeId = @newDdlValue
  762. IF @newDdlValue IS NULL
  763. BEGIN
  764. EXEC proc_errorHandler 1, 'Please enter valid payment mode', @tranId
  765. RETURN
  766. END
  767. BEGIN TRAN
  768. IF EXISTS(SELECT 'X' FROM remitTranTemp WHERE id = @tranId)
  769. BEGIN
  770. UPDATE remitTranTemp SET paymentMethod = @paymentMode, pbank = CASE @paymentMode WHEN 'CASH PAYMENT' THEN NULL
  771. ELSE pbank END
  772. WHERE id = @tranId
  773. UPDATE RECEIVERINFORMATION SET paymentMode = @newDdlValue
  774. WHERE receiverId = @receiverId
  775. END
  776. ELSE IF EXISTS(SELECT 'X' FROM remitTran WHERE id = @tranId)
  777. BEGIN
  778. UPDATE remitTran SET paymentMethod = @paymentMode, pbank = CASE @paymentMode WHEN 'CASH PAYMENT' THEN NULL
  779. ELSE pbank END
  780. WHERE id = @tranId
  781. UPDATE RECEIVERINFORMATION SET paymentMode = @newDdlValue
  782. WHERE receiverId = @receiverId
  783. END
  784. SET @message = 'Payment Mode:' + ISNULL(@oldValue, '') + ' has been changed to ' + ISNULL(@paymentMode, '')
  785. INSERT INTO tranModifyLog(tranId,message,createdBy,createdDate,MsgType, status)
  786. SELECT @tranId,@message,@user,@nepDate,'MODIFY' , 'APPROVED'
  787. COMMIT TRAN
  788. END
  789. --For mobile broadcast notification
  790. --IF EXISTS(SELECT * FROM REMITTRAN(NOLOCK) WHERE ID=@tranId AND TRANTYPE='M')
  791. --BEGIN
  792. -- EXEC ProcBroadCastMobile @Flag='txn-amendment', @RowId=@tranId, @ControlNo=@controlNo, @CustomerId=@customerId
  793. --END
  794. select '0' errorCode,'Record has been updated successfully.' msg,@tranId id,@controlNo Extra
  795. --EXEC proc_errorHandler 0, 'Record has been updated successfully.', @tranId
  796. END
  797. --## Direct HOLD TXN modification
  798. IF @flag='uHoldtxn'
  799. BEGIN
  800. IF @fieldName='senderName'
  801. BEGIN
  802. SET @xml = @fieldValue
  803. SELECT
  804. @firstName = p.value('@firstName','VARCHAR(50)')
  805. ,@middleName = p.value('@middleName','VARCHAR(50)')
  806. ,@lastName1 = p.value('@firstLastName','VARCHAR(50)')
  807. ,@lastName2 = p.value('@secondLastName','VARCHAR(50)')
  808. FROM @xml.nodes('/root/row') AS tmp(p)
  809. IF @firstName IS NULL
  810. BEGIN
  811. EXEC proc_errorHandler 1, 'Please enter valid first name!', @tranId
  812. RETURN
  813. END
  814. SELECT @firstName = UPPER(@firstName), @middleName = UPPER(@middleName), @lastName1 = UPPER(@lastName1), @lastName2 = UPPER(@lastName2)
  815. SET @senderName = ISNULL(@firstName, '') + ISNULL(' ' + @middleName, '') + ISNULL(' ' + @lastName1, '') + ISNULL(' ' + @lastName2, '')
  816. BEGIN TRAN
  817. UPDATE tranSendersTemp SET
  818. firstName = @senderName
  819. ,middleName = null
  820. ,lastName1 = null
  821. ,lastName2 = null
  822. WHERE tranId = @tranId
  823. UPDATE remitTranTemp SET
  824. senderName = UPPER(@senderName)
  825. WHERE id = @tranId
  826. SET @message = 'Sender Name:'+ ISNULL(@oldValue, '') + ' has been changed to ' + ISNULL(@firstName, '') + ISNULL(' ' + @middleName, '') + ISNULL(' ' + @lastName1, '') + ISNULL(' ' +@lastName2, '')
  827. INSERT INTO tranModifyLog (tranId,message,createdBy,createdDate,MsgType)
  828. SELECT @tranId, @message, @user,@nepDate,'MODIFY'
  829. COMMIT TRAN
  830. END
  831. ELSE IF @fieldName='receiverName'
  832. BEGIN
  833. SET @xml = @fieldValue
  834. SELECT
  835. @firstName = p.value('@firstName','VARCHAR(50)')
  836. ,@middleName = p.value('@middleName','VARCHAR(50)')
  837. ,@lastName1 = p.value('@firstLastName','VARCHAR(50)')
  838. ,@lastName2 = p.value ('@secondLastName','VARCHAR(50)')
  839. FROM @xml.nodes('/root/row') AS tmp(p)
  840. IF @firstName is null
  841. BEGIN
  842. EXEC proc_errorHandler 1, 'Please enter valid first name!' , @tranId
  843. RETURN
  844. END
  845. SELECT @firstName = UPPER(@firstName), @middleName = UPPER(@middleName), @lastName1 = UPPER(@lastName1), @lastName2 = UPPER(@lastName2)
  846. SET @receiverName = ISNULL(@firstName, '') + ISNULL(' ' + @middleName, '') + ISNULL(' ' + @lastName1, '') + ISNULL(' ' + @lastName2, '')
  847. BEGIN TRAN
  848. UPDATE tranReceiversTemp SET
  849. firstName = @receiverName
  850. ,middleName = null
  851. ,lastName1 = null
  852. ,lastName2 = null
  853. WHERE tranId = @tranId
  854. UPDATE remitTranTemp SET
  855. receiverName = upper(@receiverName)
  856. WHERE id = @tranId
  857. SET @message = 'Receiver Name:' + ISNULL(@oldValue, '') + ' has been changed to ' + ISNULL(@firstName, '') + ISNULL(' ' + @middleName, '') + ISNULL(' ' + @lastName1, '') + ISNULL(' ' + @lastName2, '')
  858. INSERT INTO tranModifyLog (tranId,message,createdBy,createdDate,MsgType)
  859. SELECT @tranId,@message,@user,@nepDate,'MODIFY'
  860. COMMIT TRAN
  861. END
  862. ELSE IF @fieldName='sIdType'
  863. BEGIN
  864. IF @newDdlValue is null
  865. BEGIN
  866. EXEC proc_errorHandler 1, 'Please enter valid id type!', @tranId
  867. RETURN
  868. END
  869. BEGIN TRAN
  870. UPDATE tranSendersTemp SET
  871. idType = @newDdlValue
  872. WHERE tranId = @tranId
  873. SET @message = 'Sender Id Type:' + ISNULL(@oldValue, '') + ' has been changed to ' + ISNULL(@newDdlValue, '')
  874. INSERT INTO tranModifyLog(tranId,message,createdBy,createdDate,MsgType)
  875. SELECT @tranId,@message,@user,@nepDate,'MODIFY'
  876. COMMIT TRAN
  877. END
  878. ELSE IF @fieldName='rIdType'
  879. BEGIN
  880. IF @newDdlValue is null
  881. BEGIN
  882. EXEC proc_errorHandler 1, 'Please enter valid id type!', @tranId
  883. RETURN
  884. END
  885. BEGIN TRAN
  886. UPDATE tranReceiversTemp SET
  887. idType = @newDdlValue
  888. WHERE tranId = @tranId
  889. SET @message = 'Receiver Id Type:'+ isnull(@oldValue,'')+' has been changed to '+isnull(@newDdlValue,'')
  890. INSERT INTO tranModifyLog (tranId,message,createdBy,createdDate,MsgType)
  891. SELECT @tranId,@message,@user,@nepDate,'MODIFY'
  892. COMMIT TRAN
  893. END
  894. ELSE IF @fieldName='relationship'
  895. BEGIN
  896. IF @newDdlValue IS NULL
  897. BEGIN
  898. EXEC proc_errorHandler 1, 'Please enter valid Receiver relationship with sender!', @tranId
  899. RETURN
  900. END
  901. BEGIN TRAN
  902. UPDATE remitTranTemp SET
  903. relWithSender = @newDdlValue
  904. WHERE id = @tranId
  905. SET @message = 'Receiver relationship with sender :'+ ISNULL(@oldValue,'')+' has been changed to '+ISNULL(@newDdlValue,'')
  906. INSERT INTO tranModifyLog(tranId,MESSAGE,createdBy,createdDate,MsgType)
  907. SELECT @tranId,@message,@user,@nepDate,'MODIFY'
  908. COMMIT TRAN
  909. END
  910. ELSE IF @fieldName='rAddress'
  911. BEGIN
  912. IF @newTxtValue is null
  913. BEGIN
  914. EXEC proc_errorHandler 1, 'Please enter valid address!', @tranId
  915. RETURN
  916. END
  917. BEGIN TRAN
  918. UPDATE tranReceiversTemp SET
  919. address = @newTxtValue
  920. WHERE tranId = @tranId
  921. SET @message = 'Receiver Address:'+ isnull(@oldValue,'')+' has been changed to '+isnull(@newTxtValue,'')
  922. INSERT INTO tranModifyLog(tranId,message,createdBy,createdDate,MsgType)
  923. SELECT @tranId, @message, @user, @nepDate, 'MODIFY'
  924. COMMIT TRAN
  925. END
  926. ELSE IF @fieldName='sAddress'
  927. BEGIN
  928. IF @newTxtValue is null
  929. BEGIN
  930. EXEC proc_errorHandler 1, 'Please enter valid address!', @tranId
  931. RETURN
  932. END
  933. UPDATE tranSendersTemp SET
  934. address = @newTxtValue
  935. WHERE tranId = @tranId
  936. SET @message = 'Sender Address:' + ISNULL(@oldValue,'') + ' has been changed to ' + ISNULL(@newTxtValue, '')
  937. INSERT INTO tranModifyLog(tranId,message,createdBy,createdDate,MsgType)
  938. SELECT @tranId,@message,@user,@nepDate,'MODIFY'
  939. END
  940. ELSE IF @fieldName='sContactNo'
  941. BEGIN
  942. IF @contactNo IS NULL
  943. BEGIN
  944. EXEC proc_errorHandler 1, 'Please enter valid contact number!', @tranId
  945. RETURN
  946. END
  947. UPDATE tranSendersTemp SET
  948. mobile = @contactNo
  949. WHERE tranId = @tranId
  950. SET @message = 'Sender Contact No:'+ ISNULL(@oldValue,'')+' has been changed to '+ISNULL(@contactNo,'')
  951. INSERT INTO tranModifyLog(tranId,MESSAGE,createdBy,createdDate,MsgType)
  952. SELECT @tranId,@message,@user,@nepDate,'MODIFY'
  953. END
  954. ELSE IF @fieldName='rTelNo'
  955. BEGIN
  956. IF @contactNo IS NULL
  957. BEGIN
  958. EXEC proc_errorHandler 1, 'Please enter valid telephone number!', @tranId
  959. RETURN
  960. END
  961. BEGIN TRAN
  962. UPDATE tranReceiversTemp SET
  963. homephone = @contactNo
  964. WHERE tranId = @tranId
  965. SET @message = 'Receiver telephone number:'+ isnull(@oldValue,'')+' has been changed to '+isnull(@contactNo,'')
  966. INSERT INTO tranModifyLog(tranId,message,createdBy,createdDate,MsgType)
  967. SELECT @tranId,@message,@user,@nepDate,'MODIFY'
  968. COMMIT TRAN
  969. END
  970. ELSE IF @fieldName='sTelNo'
  971. BEGIN
  972. IF @contactNo is null
  973. BEGIN
  974. EXEC proc_errorHandler 1, 'Please enter valid telephone number!', @tranId
  975. RETURN
  976. END
  977. BEGIN TRAN
  978. UPDATE tranSendersTemp SET
  979. homephone = @contactNo
  980. WHERE tranId = @tranId
  981. SET @message = 'Sender telephone number:'+ isnull(@oldValue,'')+' has been changed to '+isnull(@contactNo,'')
  982. INSERT INTO tranModifyLog(tranId,message,createdBy,createdDate,MsgType)
  983. SELECT @tranId,@message,@user,@nepDate,'MODIFY'
  984. COMMIT TRAN
  985. END
  986. ELSE IF @fieldName='rContactNo'
  987. BEGIN
  988. IF @contactNo is null
  989. BEGIN
  990. EXEC proc_errorHandler 1, 'Please enter valid contact number!', @tranId
  991. RETURN
  992. END
  993. BEGIN TRAN
  994. UPDATE tranReceiversTemp SET
  995. mobile = @contactNo
  996. WHERE tranId = @tranId
  997. SET @message = 'Receiver Contact No:'+ ISNULL(@oldValue,'')+' has been changed to '+isnull(@contactNo,'')
  998. INSERT INTO tranModifyLog(tranId,message,createdBy,createdDate,MsgType)
  999. SELECT @tranId,@message,@user,@nepDate,'MODIFY'
  1000. COMMIT TRAN
  1001. END
  1002. ELSE IF @fieldName='sIdNo'
  1003. BEGIN
  1004. IF @newTxtValue is null
  1005. BEGIN
  1006. EXEC proc_errorHandler 1, 'Please enter valid id number!', @tranId
  1007. RETURN
  1008. END
  1009. BEGIN TRAN
  1010. UPDATE tranSendersTemp SET
  1011. idNumber = @newTxtValue
  1012. WHERE tranId = @tranId
  1013. SET @message = 'Sender ID No:'+ ISNULL(@oldValue,'')+' has been changed to '+ISNULL(@newTxtValue,'')
  1014. INSERT INTO tranModifyLog(tranId,message,createdBy,createdDate,MsgType)
  1015. SELECT @tranId,@message,@user,@nepDate,'MODIFY'
  1016. COMMIT TRAN
  1017. END
  1018. ELSE IF @fieldName='rIdNo'
  1019. BEGIN
  1020. IF @newTxtValue is null
  1021. BEGIN
  1022. EXEC proc_errorHandler 1, 'Please enter valid id number!', @tranId
  1023. RETURN
  1024. END
  1025. BEGIN TRAN
  1026. UPDATE tranReceiversTemp SET
  1027. idNumber = @newTxtValue
  1028. WHERE tranId = @tranId
  1029. SET @message = 'Receiver ID No:'+ ISNULL(@oldValue,'')+' has been changed to '+ISNULL(@newTxtValue,'')
  1030. INSERT INTO tranModifyLog(tranId,message,createdBy,createdDate,MsgType)
  1031. SELECT @tranId,@message,@user,@nepDate,'MODIFY'
  1032. COMMIT TRAN
  1033. END
  1034. ELSE IF @fieldName='txnTestQuestion'
  1035. BEGIN
  1036. IF @newTxtValue is null
  1037. BEGIN
  1038. EXEC proc_errorHandler 1, 'Please enter valid id number!', @tranId
  1039. RETURN
  1040. END
  1041. BEGIN TRAN
  1042. UPDATE tranSendersTemp SET
  1043. txnTestQuestion = @newTxtValue
  1044. WHERE tranId = @tranId
  1045. SET @message = 'Test Question:'+ ISNULL(@oldValue,'')+' has been changed to '+ISNULL(@newTxtValue,'')
  1046. INSERT INTO tranModifyLog(tranId,message,createdBy,createdDate,MsgType)
  1047. SELECT @tranId,@message,@user,@nepDate,'MODIFY'
  1048. COMMIT TRAN
  1049. END
  1050. ELSE IF @fieldName='txnTestAnswer'
  1051. BEGIN
  1052. IF @newTxtValue is null
  1053. BEGIN
  1054. EXEC proc_errorHandler 1, 'Please enter valid id number!', @tranId
  1055. RETURN
  1056. END
  1057. BEGIN TRAN
  1058. UPDATE tranSendersTemp SET
  1059. txnTestAnswer = @newTxtValue
  1060. WHERE tranId = @tranId
  1061. SET @message = 'Test Answer:'+ isnull(@oldValue,'')+' has been changed to '+isnull(@newTxtValue,'')
  1062. INSERT INTO tranModifyLog(tranId,message,createdBy,createdDate,MsgType)
  1063. SELECT @tranId,@message,@user,@nepDate,'MODIFY'
  1064. COMMIT TRAN
  1065. END
  1066. ELSE IF @fieldName='accountNo'
  1067. BEGIN
  1068. IF @newTxtValue IS NULL
  1069. BEGIN
  1070. EXEC proc_errorHandler 1, 'Please enter valid account number!', @tranId
  1071. RETURN
  1072. END
  1073. BEGIN TRAN
  1074. UPDATE remitTranTemp SET
  1075. accountNo = @newTxtValue
  1076. WHERE id = @tranId
  1077. SET @message = 'Account Number:'+ ISNULL(@oldValue,'')+' has been changed to '+ISNULL(@newTxtValue,'')
  1078. INSERT INTO tranModifyLog(tranId,MESSAGE,createdBy,createdDate,MsgType)
  1079. SELECT @tranId,@message,@user,@nepDate,'MODIFY'
  1080. COMMIT TRAN
  1081. END
  1082. ELSE IF @fieldName='BankName'
  1083. BEGIN
  1084. if @bankNewName is null
  1085. begin
  1086. EXEC proc_errorHandler 1, 'Please enter valid bank name!', @tranId
  1087. return
  1088. end
  1089. if @branchNewName is null
  1090. begin
  1091. EXEC proc_errorHandler 1, 'Please enter valid bank name!', @tranId
  1092. return
  1093. end
  1094. update remitTranTemp SET
  1095. pBank = @bankNewName,
  1096. pBankName=dbo.GetAgentNameFromId(@bankNewName),
  1097. pBankBranch = @branchNewName,
  1098. pBankBranchName=dbo.GetAgentNameFromId(@branchNewName)
  1099. WHERE id = @tranId
  1100. SET @message = 'Bank Name:'+ isnull(@oldValue,'')+' has been changed to '+isnull(dbo.GetAgentNameFromId(@bankNewName),'')
  1101. insert into tranModifyLog(tranId,message,createdBy,createdDate,MsgType)
  1102. select @tranId,@message,@user,@nepDate,'MODIFY'
  1103. ----DECLARE @message3 VARCHAR(200) = NULL
  1104. SET @message = 'Branch name has been changed to '+isnull(dbo.GetAgentNameFromId(@branchNewName),'')
  1105. insert into tranModifyLog(tranId,message,createdBy,createdDate,MsgType)
  1106. select @tranId,@message,@user,@nepDate,'MODIFY'
  1107. END
  1108. ELSE IF @fieldName='BranchName'
  1109. BEGIN
  1110. if @newDdlValue is null
  1111. begin
  1112. EXEC proc_errorHandler 1, 'Please enter valid branch name!', @tranId
  1113. return
  1114. end
  1115. update remitTranTemp SET
  1116. pBankBranch = @newDdlValue,
  1117. pBankBranchName=dbo.GetAgentNameFromId(@newDdlValue)
  1118. WHERE id = @tranId
  1119. SET @message = 'Branch Name:'+ isnull(@oldValue,'')+' has been changed to '+isnull(dbo.GetAgentNameFromId(@newDdlValue),'')
  1120. insert into tranModifyLog(tranId,message,createdBy,createdDate,MsgType)
  1121. select @tranId,@message,@user,@nepDate,'MODIFY'
  1122. END
  1123. ELSE IF @fieldName='pBranchName'
  1124. BEGIN
  1125. if @newDdlValue is null
  1126. begin
  1127. EXEC proc_errorHandler 1, 'Please enter valid branch name!', @tranId
  1128. return
  1129. end
  1130. select @locationCode=agentLocation from agentMaster where agentId=@newDdlValue
  1131. select @locationName=districtName from api_districtList where districtCode=@locationCode
  1132. select @oldAgentId= case when isnull(pAgent,0)=isnull(pBranch,0) then pSuperAgent else pAgent end
  1133. from remitTranTemp where id=@tranId
  1134. select @oldAgentName=agentName from agentMaster where agentId=@oldAgentId
  1135. if exists(select actAsBranch from agentMaster where agentId=@newDdlValue and actAsBranch='y')
  1136. begin
  1137. -- ## branch name
  1138. select @branchName=agentName
  1139. from agentMaster
  1140. where agentId=@newDdlValue
  1141. -- ## super agent
  1142. select @supAgentId=parentId
  1143. from agentMaster where agentId=@newDdlValue
  1144. select @supAgentName=agentName
  1145. from agentMaster where agentId=@supAgentId
  1146. -- ## update if agent act as a branch
  1147. update remitTranTemp SET
  1148. pAgent = @newDdlValue,
  1149. pBranch=@newDdlValue,
  1150. pAgentName=@branchName,
  1151. pBranchName=@branchName,
  1152. pSuperAgent=@supAgentId,
  1153. pSuperAgentName=@supAgentName
  1154. WHERE id = @tranId
  1155. -- ## update transaction log
  1156. insert into tranModifyLog(tranId,message,createdBy,createdDate,MsgType)
  1157. select @tranId,'Branch Name:'+ isnull(@oldValue,'')+' has been changed to '+isnull(@branchName,''),@user,@nepDate,'MODIFY'
  1158. insert into tranModifyLog(tranId,message,createdBy,createdDate,MsgType)
  1159. select @tranId,'Agent Name:'+ isnull(@oldAgentName,'')+' has been changed to '+isnull(@supAgentName,''),@user,@nepDate,'MODIFY'
  1160. end
  1161. else
  1162. begin
  1163. -- ## branch name & agent name
  1164. select @parentId=parentId,@branchName=agentName
  1165. from agentMaster
  1166. where agentId=@newDdlValue
  1167. select @agentName=agentName
  1168. from agentMaster
  1169. where agentId=@parentId
  1170. -- ## super agent
  1171. select @supAgentId=parentId
  1172. from agentMaster where agentId=@parentId
  1173. select @supAgentName=agentName
  1174. from agentMaster where agentId=@supAgentId
  1175. -- ## update remitTran
  1176. update remitTranTemp SET
  1177. pAgent = @parentId,
  1178. pBranch=@newDdlValue,
  1179. pAgentName=@agentName,
  1180. pBranchName=@branchName,
  1181. pSuperAgent=@supAgentId,
  1182. pSuperAgentName=@supAgentName
  1183. WHERE id = @tranId
  1184. -- ## update transaction log
  1185. insert into tranModifyLog(tranId,message,createdBy,createdDate,MsgType)
  1186. select @tranId,'Branch Name:'+ isnull(@oldValue,'')+' has been changed to '+isnull(@branchName,''),@user,@nepDate,'MODIFY'
  1187. insert into tranModifyLog(tranId,message,createdBy,createdDate,MsgType)
  1188. select @tranId,'Agent Name:'+ isnull(@oldAgentName,'')+' has been changed to '+isnull(@agentName,''),@user,@nepDate,'MODIFY'
  1189. end
  1190. END
  1191. EXEC proc_errorHandler 0, 'Record has been updated successfully.', @tranId
  1192. END
  1193. IF @flag='sa'
  1194. BEGIN
  1195. SELECT pBank FROM remitTran with(nolock) WHERE id=@tranId
  1196. END
  1197. IF @flag='branchId'
  1198. BEGIN
  1199. DECLARE @bankId BIGINT
  1200. SELECT @bankId = pBank FROM remitTran with(nolock) WHERE id=@tranId
  1201. SELECT MASTER_BANK_ID FROM API_BANK_LIST_MASTER am
  1202. inner join API_BANK_LIST ab on ab.JME_BANK_CODE = am.JME_BANK_CODE
  1203. where BANK_ID = @bankId
  1204. RETURN @bankId
  1205. END
  1206. --## Approve Modification
  1207. IF @flag = 'approveAll'
  1208. BEGIN
  1209. SELECT
  1210. @controlNoEncrypted = controlNo,
  1211. @pCountry = pCountry,
  1212. @controlNo = dbo.fnadecryptstring(controlNo)
  1213. FROM remitTran WITH(NOLOCK) WHERE id = @tranId
  1214. IF OBJECT_ID('tempdb..#TEMPTABLE') IS NOT NULL
  1215. DROP TABLE #TEMPTABLE
  1216. CREATE TABLE #TEMPTABLE
  1217. (
  1218. tranId INT NULL,
  1219. modifyId INT NULL,
  1220. fieldName VARCHAR(100) NULL,
  1221. fieldValue VARCHAR(MAX) NULL,
  1222. oldValue VARCHAR(500) NULL,
  1223. MSG VARCHAR(MAX) NULL
  1224. )
  1225. INSERT INTO #TEMPTABLE(tranId,modifyId,fieldName,fieldValue,oldValue,MSG)
  1226. SELECT @tranId,rowId,fieldName,fieldValue,oldValue,message
  1227. FROM tranModifyLog with(nolock) WHERE tranId = @tranId AND STATUS = 'Request'
  1228. ALTER TABLE #TEMPTABLE ADD rowId INT IDENTITY(1,1)
  1229. SELECT @tranType = tranType FROM remitTran (NOLOCK) WHERE id = @tranId
  1230. SELECT @MAXID =MAX(rowId) FROM #TEMPTABLE
  1231. SET @MINID = 1
  1232. WHILE @MAXID >= @MINID
  1233. BEGIN
  1234. SELECT @modifyId = modifyId,
  1235. @fieldName = fieldName,
  1236. @fieldValue = fieldValue,
  1237. @oldValue = oldValue
  1238. FROM #TEMPTABLE WITH(NOLOCK)
  1239. WHERE rowId = @MINID
  1240. BEGIN TRAN
  1241. IF @fieldName='senderName'
  1242. BEGIN
  1243. SET @xml = @fieldValue
  1244. SELECT
  1245. @firstName = p.value('@firstName','VARCHAR(50)')
  1246. ,@middleName = p.value('@middleName','VARCHAR(50)')
  1247. ,@lastName1 = p.value('@firstLastName','VARCHAR(50)')
  1248. ,@lastName2 = p.value('@secondLastName','VARCHAR(50)')
  1249. FROM @xml.nodes('/root/row') AS tmp(p)
  1250. SELECT @firstName = UPPER(@firstName), @middleName = UPPER(@middleName), @lastName1 = UPPER(@lastName1), @lastName2 = UPPER(@lastName2)
  1251. SET @senderName = @firstName + ISNULL(' ' + @middleName, '') + ISNULL(' ' + @lastName1, '') + ISNULL(' ' + @lastName2, '')
  1252. UPDATE tranSenders SET
  1253. firstName = @firstName
  1254. ,middleName = @middleName
  1255. ,lastName1 = @lastName1
  1256. ,lastName2 = @lastName2
  1257. ,fullName = @senderName
  1258. WHERE tranId = @tranId
  1259. UPDATE remitTran SET senderName = @senderName WHERE id = @tranId
  1260. UPDATE customerTxnHistory SET senderName = @senderName WHERE refNo = dbo.encryptdb(@controlNo)
  1261. --## update accounting db
  1262. UPDATE FastMoneyPro_account.dbo.remit_trn_master SET Sender_Name = @senderName WHERE trn_ref_no = dbo.encryptdb(@controlNo)
  1263. SET @message = 'Sender Name [<b>'+@oldValue+'</b>] has been replaced to [<b>' + ISNULL(@firstName, '') + ISNULL(' ' + @middleName, '') + ISNULL(' ' + @lastName1, '') + ISNULL(' ' +@lastName2, '')+'</b>]'
  1264. EXEC proc_ofacTracker @flag = 't', @name = @senderName, @Result = @senderOfacRes OUTPUT
  1265. END
  1266. ELSE IF @fieldName='receiverName'
  1267. BEGIN
  1268. SET @xml = @fieldValue
  1269. SELECT
  1270. @firstName = p.value('@firstName','VARCHAR(50)')
  1271. ,@middleName = p.value('@middleName','VARCHAR(50)')
  1272. ,@lastName1 = p.value('@firstLastName','VARCHAR(50)')
  1273. ,@lastName2 = p.value ('@secondLastName','VARCHAR(50)')
  1274. FROM @xml.nodes('/root/row') AS tmp(p)
  1275. SELECT @firstName = UPPER(@firstName), @middleName = UPPER(@middleName), @lastName1 = UPPER(@lastName1), @lastName2 = UPPER(@lastName2)
  1276. SET @receiverName = @firstName + ISNULL(' ' + @middleName, '') + ISNULL(' ' + @lastName1, '') + ISNULL(' ' + @lastName2, '')
  1277. UPDATE tranReceivers SET
  1278. firstName = @firstName
  1279. ,middleName = @middleName
  1280. ,lastName1 = @lastName1
  1281. ,lastName2 = @lastName2
  1282. ,fullName = @receiverName
  1283. WHERE tranId = @tranId
  1284. UPDATE remitTran SET receiverName = @receiverName WHERE id = @tranId
  1285. UPDATE customerTxnHistory SET receiverName = @receiverName WHERE refNo = dbo.encryptdb(@controlNo)
  1286. --## update accounting db
  1287. UPDATE FastMoneyPro_account.dbo.remit_trn_master SET Receiver_Name = @receiverName WHERE trn_ref_no = dbo.encryptdb(@controlNo)
  1288. SET @message = 'Receiver Name [<b>'+@oldValue+'</b>] has been replaced to [<b>' + ISNULL(@firstName, '') + ISNULL(' ' + @middleName, '') + ISNULL(' ' + @lastName1, '') + ISNULL(' ' + @lastName2, '')+'</b>]'
  1289. EXEC proc_ofacTracker @flag = 't', @name = @receiverName, @Result = @receiverOfacRes OUTPUT
  1290. END
  1291. ELSE IF @fieldName='rIdType'
  1292. BEGIN
  1293. UPDATE tranReceivers SET idType = @fieldValue WHERE tranId = @tranId
  1294. SET @message = 'Receiver Id Type [<b>'+ISNULL(@oldValue, '') +'</b>] has been replaced to [<b>'+isnull(@fieldValue,'')+'</b>]'
  1295. END
  1296. ELSE IF @fieldName='rAddress'
  1297. BEGIN
  1298. UPDATE tranReceivers SET address = @fieldValue WHERE tranId = @tranId
  1299. SET @message = 'Receiver Address [<b>'+ISNULL(@oldValue, '')+'</b>] has been replaced to [<b>'+isnull(@fieldValue,'')+'</b>]'
  1300. END
  1301. ELSE IF @fieldName='rContactNo'
  1302. BEGIN
  1303. UPDATE tranReceivers SET mobile = @fieldValue WHERE tranId = @tranId
  1304. SET @message = 'Receiver Contact No [<b>'+ISNULL(@oldValue, '')+'</b>] has been replaced to [<b>'+isnull(@fieldValue,'')+'</b>]'
  1305. END
  1306. ELSE IF @fieldName='rIdNo'
  1307. BEGIN
  1308. UPDATE tranReceivers SET idNumber = @fieldValue WHERE tranId = @tranId
  1309. SET @message = 'Receiver ID No [<b>'+ISNULL(@oldValue, '')+'</b>] has been replaced to [<b>'+isnull(@fieldValue,'')+'</b>]'
  1310. END
  1311. ELSE IF @fieldName='accountNo'
  1312. BEGIN
  1313. UPDATE remitTran SET accountNo = @fieldValue WHERE id = @tranId
  1314. IF @tranType = 'I'
  1315. UPDATE FastMoneyPro_account.dbo.remit_trn_master SET customerId = @fieldValue WHERE trn_ref_no = dbo.encryptdb(@controlNo)
  1316. SET @message = 'Receiver Bank Ac No [<b>'+ISNULL(@oldValue, '')+'</b>] has been replaced to [<b>'+isnull(@fieldValue,'')+'</b>]'
  1317. END
  1318. UPDATE tranModifyLog SET
  1319. MESSAGE = @message
  1320. ,MsgType = 'MODIFY'
  1321. ,resolvedBy = @user
  1322. ,resolvedDate = @nepDate
  1323. ,status = 'approved'
  1324. WHERE rowId = @modifyId
  1325. COMMIT TRAN
  1326. SET @MINID = @MINID + 1
  1327. END
  1328. SELECT @branchId= sBranch,@user = createdBy FROM remitTran WITH(NOLOCK) WHERE id = @tranId
  1329. SELECT @emailId= dbo.FNAGetBranchEmail(@branchId,@user)
  1330. UPDATE remitTran SET tranStatus = 'Payment' WHERE id = @tranId
  1331. IF ISNULL(@senderOfacRes, '') <> ''
  1332. BEGIN
  1333. SET @ofacReason = 'Matched by sender name during transaction ammendment'
  1334. SET @ofacRes = @senderOfacRes
  1335. END
  1336. IF ISNULL(@receiverOfacRes, '') <> ''
  1337. BEGIN
  1338. SET @ofacReason = 'Matched by receiver name during transaction ammendment'
  1339. SET @ofacRes = @receiverOfacRes
  1340. END
  1341. IF ISNULL(@senderOfacRes, '') <> '' AND ISNULL(@receiverOfacRes, '') <> ''
  1342. BEGIN
  1343. SET @ofacReason = 'Matched by both sender name and receiver name during transaction ammendment'
  1344. SET @ofacRes = @senderOfacRes + ',' + @receiverOfacRes
  1345. END
  1346. IF ISNULL(@ofacRes, '') <> ''
  1347. BEGIN
  1348. INSERT INTO remitTranOfac(TranId, blackListId, reason)
  1349. SELECT @tranId, @ofacRes, @ofacReason
  1350. UPDATE remitTran SET
  1351. tranStatus = 'OFAC'
  1352. WHERE id = @tranId
  1353. IF @pCountry = 'Nepal'
  1354. BEGIN
  1355. INSERT INTO rs_remitTranStatusUpdate(
  1356. controlNo, tranStatus, updatedBy, updatedDate
  1357. )
  1358. SELECT @controlNoEncrypted, 'OFAC', @user, @nepDate
  1359. END
  1360. RETURN
  1361. END
  1362. EXEC proc_errorHandler 0,'Modification Request Approved successfully',@emailId
  1363. SET @user = 'S:' + @user
  1364. END
  1365. --## Reject Modification
  1366. IF @flag = 'reject'
  1367. BEGIN
  1368. SELECT @controlNoEncrypted = controlNo, @pCountry = pCountry FROM remitTran WITH(NOLOCK) WHERE id = @tranId
  1369. BEGIN TRAN
  1370. INSERT INTO tranModifyRejectLog(tranId, controlNo, message, createdBy, createdDate, rejectedBy, rejectedDate, fieldName, fieldValue)
  1371. SELECT tranId, controlNo, message, createdBy, createdDate, @user, getdate(), fieldName, fieldValue FROM tranModifyLog WHERE tranId = @tranId AND STATUS = 'Request'
  1372. DELETE FROM tranModifyLog WHERE tranId = @tranId AND STATUS = 'Request'
  1373. UPDATE remitTran SET tranStatus = 'Payment' WHERE id = @tranId
  1374. COMMIT TRAN
  1375. EXEC proc_errorHandler 0,'Modification request rejected successfully',@controlNoEncrypted
  1376. END
  1377. IF @flag ='branchByTranId'
  1378. BEGIN
  1379. DECLARE @pBank INT
  1380. SELECT @pBank = pBank, @pBankType = pBankType FROM vwRemitTran WITH(NOLOCK) WHERE id = @tranId
  1381. IF @pBankType = 'I'
  1382. BEGIN
  1383. SELECT
  1384. agentId
  1385. ,agentName
  1386. FROM agentMaster WITH(NOLOCK) WHERE parentId = @pBank order by agentName
  1387. END
  1388. ELSE IF @pBankType = 'E'
  1389. BEGIN
  1390. SELECT
  1391. agentId = extBankId
  1392. ,agentName = branchName
  1393. FROM externalBankBranch WITH(NOLOCK) WHERE extBankId = @pBank order by branchName
  1394. END
  1395. END
  1396. END TRY
  1397. BEGIN CATCH
  1398. IF @@TRANCOUNT > 0
  1399. ROLLBACK TRANSACTION
  1400. DECLARE @errorMessage VARCHAR(MAX)
  1401. SET @errorMessage = ERROR_MESSAGE()
  1402. EXEC proc_errorHandler 1, @errorMessage, @tranId
  1403. END CATCH