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.

553 lines
39 KiB

1 year ago
  1. USE [FastMoneyPro_Remit]
  2. GO
  3. /****** Object: StoredProcedure [dbo].[proc_modifyTXNEduPay] Script Date: 9/27/2019 1:30:14 PM ******/
  4. SET ANSI_NULLS ON
  5. GO
  6. SET QUOTED_IDENTIFIER ON
  7. GO
  8. /*
  9. EXEC [proc_modifyTXN] @flag = 'u', @user = 'admin', @tranId = '2',
  10. @fieldName = 'senderName', @oldValue = 'Shiva Khanal', @newTxtValue = null,
  11. @newDdlValue = null, @firstName = 'Bijay', @middleName = null, @lastName1 = 'Shahi', @lastName2 = null
  12. */
  13. CREATE proc [dbo].[proc_modifyTXNEduPay]
  14. @flag VARCHAR(50) = NULL
  15. ,@user VARCHAR(30) = NULL
  16. ,@tranId INT = NULL
  17. ,@fieldName VARCHAR(200) = NULL
  18. ,@oldValue VARCHAR(200) = NULL
  19. ,@newTxtValue VARCHAR(200) = NULL
  20. ,@newDdlValue VARCHAR(200) = NULL
  21. ,@firstName VARCHAR(200) = NULL
  22. ,@middleName VARCHAR(200) = NULL
  23. ,@lastName1 VARCHAR(200) = NULL
  24. ,@lastName2 VARCHAR(200) = NULL
  25. ,@contactNo VARCHAR(200) = NULL
  26. ,@bankNewName VARCHAR(100) = NULL
  27. ,@branchNewName VARCHAR(100) = NULL
  28. ,@isAPI CHAR(1) = NULL
  29. AS
  30. SET NOCOUNT ON
  31. SET XACT_ABORT ON
  32. BEGIN TRY
  33. CREATE TABLE #msg(errorCode INT, msg VARCHAR(100), id INT)
  34. DECLARE @controlNo varchar(30), @message VARCHAR(100), @agentRefId VARCHAR(15)
  35. SET @agentRefId = '1' + LEFT(CAST(ABS(CHECKSUM(NEWID())) AS VARCHAR(10)) + '000000000', 8)
  36. SELECT @controlNo = dbo.FNADecryptString(controlNo) FROM remitTran WITH(NOLOCK) WHERE id = @tranId
  37. IF @flag='u'
  38. BEGIN
  39. IF @fieldName='senderName'
  40. BEGIN
  41. if @firstName is null or @lastName1 is null
  42. begin
  43. EXEC proc_errorHandler 1, 'Please enter valid first name and first last name!', @tranId
  44. return
  45. end
  46. update tranSenders SET
  47. firstName = @firstName
  48. ,middleName = @middleName
  49. ,lastName1 = @lastName1
  50. ,lastName2 = @lastName2
  51. WHERE tranId = @tranId
  52. SET @message = 'Sender Name:'+ ISNULL(@oldValue, '') + ' has been changed to ' + ISNULL(@firstName, '') + ISNULL(' ' + @middleName, '') + ISNULL(' ' + @lastName1, '') + ISNULL(' ' +@lastName2, '')
  53. insert into tranModifyLog (tranId,message,createdBy,createdDate,MsgType)
  54. select @tranId, @message, @user,dbo.FNAGetDateInNepalTZ(),'M'
  55. end
  56. ELSE IF @fieldName='receiverName'
  57. BEGIN
  58. if @firstName is null or @lastName1 is null
  59. begin
  60. EXEC proc_errorHandler 1, 'Please enter valid first name and first last name!' , @tranId
  61. return
  62. end
  63. update tranReceivers SET
  64. firstName = @firstName
  65. ,middleName = @middleName
  66. ,lastName1 = @lastName1
  67. ,lastName2 = @lastName2
  68. WHERE tranId = @tranId
  69. SET @message = 'Receiver Name:' + ISNULL(@oldValue, '') + ' has been changed to ' + ISNULL(@firstName, '') + ISNULL(' ' + @middleName, '') + ISNULL(' ' + @lastName1, '') + ISNULL(' ' + @lastName2, '')
  70. insert into tranModifyLog (tranId,message,createdBy,createdDate,MsgType)
  71. select @tranId,@message,@user,dbo.FNAGetDateInNepalTZ(),'M'
  72. end
  73. ELSE IF @fieldName='sIdType'
  74. BEGIN
  75. if @newDdlValue is null
  76. begin
  77. EXEC proc_errorHandler 1, 'Please enter valid id type!', @tranId
  78. return
  79. end
  80. update tranSenders SET
  81. idType = @newDdlValue
  82. WHERE tranId = @tranId
  83. SET @message = 'Sender Id Type:' + ISNULL(@oldValue, '') + ' has been changed to ' + ISNULL(@newDdlValue, '')
  84. insert into tranModifyLog(tranId,message,createdBy,createdDate,MsgType)
  85. select @tranId,@message,@user,dbo.FNAGetDateInNepalTZ(),'M'
  86. end
  87. ELSE IF @fieldName='rAddress'
  88. BEGIN
  89. if @newTxtValue is null
  90. begin
  91. EXEC proc_errorHandler 1, 'Please enter valid address!', @tranId
  92. return
  93. end
  94. update tranReceivers SET
  95. address = @newTxtValue
  96. WHERE tranId = @tranId
  97. SET @message = 'Receiver Address:'+ isnull(@oldValue,'')+' has been changed to '+isnull(@newTxtValue,'')
  98. INSERT INTO tranModifyLog(tranId,message,createdBy,createdDate,MsgType)
  99. SELECT @tranId, @message, @user, dbo.FNAGetDateInNepalTZ(), 'M'
  100. END
  101. ELSE IF @fieldName='sAddress'
  102. BEGIN
  103. if @newTxtValue is null
  104. begin
  105. EXEC proc_errorHandler 1, 'Please enter valid address!', @tranId
  106. return
  107. end
  108. update tranSenders SET
  109. address = @newTxtValue
  110. WHERE tranId = @tranId
  111. SET @message = 'Sender Address:' + ISNULL(@oldValue,'') + ' has been changed to ' + ISNULL(@newTxtValue, '')
  112. INSERT INTO tranModifyLog(tranId,message,createdBy,createdDate,MsgType)
  113. select @tranId,@message,@user,dbo.FNAGetDateInNepalTZ(),'M'
  114. end
  115. ELSE IF @fieldName='sContactNo'
  116. BEGIN
  117. if @contactNo is null
  118. begin
  119. EXEC proc_errorHandler 1, 'Please enter valid contact number!', @tranId
  120. return
  121. end
  122. update tranSenders SET
  123. mobile = @contactNo
  124. WHERE tranId = @tranId
  125. SET @message = 'Sender Contact No:'+ isnull(@oldValue,'')+' has been changed to '+isnull(@contactNo,'')
  126. insert into tranModifyLog(tranId,message,createdBy,createdDate,MsgType)
  127. select @tranId,@message,@user,dbo.FNAGetDateInNepalTZ(),'M'
  128. end
  129. ELSE IF @fieldName='rContactNo'
  130. BEGIN
  131. if @contactNo is null
  132. begin
  133. EXEC proc_errorHandler 1, 'Please enter valid contact number!', @tranId
  134. return
  135. end
  136. update tranReceivers SET
  137. mobile = @contactNo
  138. WHERE tranId = @tranId
  139. SET @message = 'Receiver Contact No:'+ isnull(@oldValue,'')+' has been changed to '+isnull(@contactNo,'')
  140. insert into tranModifyLog(tranId,message,createdBy,createdDate,MsgType)
  141. select @tranId,@message,@user,dbo.FNAGetDateInNepalTZ(),'M'
  142. end
  143. ELSE IF @fieldName='sIdNo'
  144. BEGIN
  145. if @newTxtValue is null
  146. begin
  147. EXEC proc_errorHandler 1, 'Please enter valid id number!', @tranId
  148. return
  149. end
  150. update tranSenders SET
  151. idNumber = @newTxtValue
  152. WHERE tranId = @tranId
  153. SET @message = 'Sender ID No:'+ isnull(@oldValue,'')+' has been changed to '+isnull(@newTxtValue,'')
  154. insert into tranModifyLog(tranId,message,createdBy,createdDate,MsgType)
  155. select @tranId,@message,@user,dbo.FNAGetDateInNepalTZ(),'M'
  156. end
  157. ELSE IF @fieldName='pAgentLocation'
  158. BEGIN
  159. DECLARE @pDistrict VARCHAR(100), @pDistrictId INT, @pState VARCHAR(100), @pStateId INT
  160. IF @newDdlValue IS NULL
  161. BEGIN
  162. EXEC proc_errorHandler 1, 'Please enter valid agent payout location!', @tranId
  163. RETURN
  164. END
  165. DECLARE
  166. @deliveryMethodId INT
  167. ,@deliveryMethod VARCHAR(50)
  168. ,@sBranch INT
  169. ,@pSuperAgent INT
  170. ,@sCountryId INT
  171. ,@sCountry VARCHAR(100)
  172. ,@pCountryId INT
  173. ,@pCountry VARCHAR(100)
  174. ,@pLocation INT
  175. ,@agentId INT
  176. ,@amount MONEY
  177. ,@oldSc MONEY
  178. ,@newSc MONEY
  179. ,@collCurr VARCHAR(3)
  180. SELECT
  181. @deliveryMethod = paymentMethod
  182. ,@sBranch = sBranch
  183. ,@pSuperAgent = pSuperAgent
  184. ,@sCountry = sCountry
  185. ,@pCountry = pCountry
  186. ,@agentId = pBranch
  187. ,@amount = tAmt
  188. ,@oldSc = serviceCharge
  189. ,@collCurr = collCurr
  190. ,@controlNo = dbo.FNADecryptString(controlNo)
  191. ,@pLocation = pLocation
  192. FROM remitTran WITH(NOLOCK)
  193. WHERE id = @tranId
  194. --Check if txn is paid from View
  195. IF EXISTS(SELECT 'X' FROM hremit.dbo.AccountTransaction WITH(NOLOCK) WHERE refno = dbo.encryptDbLocal(@controlNo) AND [status] = 'Paid')
  196. BEGIN
  197. SET @message = 'Transaction ' + @controlNo + ' is paid. Cannot modify transaction'
  198. EXEC proc_errorHandler 1, @message, @tranId
  199. RETURN
  200. END
  201. IF (@pLocation = 137 AND @newDdlValue <> 137)
  202. BEGIN
  203. EXEC proc_errorHandler 1, 'Service Charge or Commission for this location varies. Cannot modify Location.', @tranId
  204. RETURN
  205. END
  206. IF (@newDdlValue = 137 AND @pLocation <> 137)
  207. BEGIN
  208. EXEC proc_errorHandler 1, 'Service Charge or Commission for this location varies. Cannot modify Location.', @tranId
  209. RETURN
  210. END
  211. SELECT @deliveryMethodId = serviceTypeId FROM serviceTypeMaster WITH(NOLOCK) WHERE typeTitle = @deliveryMethod AND ISNULL(isDeleted, 'N') = 'N'
  212. SELECT @sCountryId = countryId FROM countryMaster WITH(NOLOCK) WHERE countryName = @sCountry
  213. SELECT @pCountryId = countryId FROM countryMaster WITH(NOLOCK) WHERE countryName = @pCountry
  214. IF(@sCountry = 'Nepal')
  215. SELECT @newSc = ISNULL(serviceCharge, 0) FROM dbo.FNAGetDomesticSendComm(@sBranch, NULL, @newDdlValue, @deliveryMethodId, @amount)
  216. ELSE
  217. SELECT @newSc = ISNULL(amount, -1) FROM [dbo].FNAGetSC(@sBranch, @pSuperAgent, @pCountryId, @newDdlValue, @agentId , @deliveryMethodId, @amount, @collCurr)
  218. IF (@oldSc <> @newSc)
  219. BEGIN
  220. EXEC proc_errorHandler 1, 'Service charge for this location varies. Cannot modify location.', @tranId
  221. RETURN
  222. END
  223. SELECT @pDistrictId = districtId FROM apiLocationMapping WITH(NOLOCK) WHERE apiDistrictCode = @newDdlValue
  224. SELECT @pDistrict = districtName, @pStateId = zone FROM zoneDistrictMap WITH(NOLOCK) WHERE districtId = @pDistrictId
  225. SELECT @pState = stateName FROM countryStateMaster WITH(NOLOCK) WHERE stateId = @pStateId
  226. UPDATE remitTran SET
  227. pLocation = @newDdlValue
  228. ,pDistrict = @pDistrict
  229. ,pState = @pState
  230. WHERE id = @tranId
  231. SELECT @message = 'Agent Payout Location :' + ISNULL(@oldValue,'') + ' has been changed to ' + ISNULL(districtName, '') FROM api_districtList WHERE districtCode = @newDdlValue
  232. INSERT INTO tranModifyLog(tranId,message,createdBy,createdDate,MsgType)
  233. SELECT @tranId,@message,@user,dbo.FNAGetDateInNepalTZ(),'M'
  234. END
  235. ELSE IF @fieldName='accountNo'
  236. BEGIN
  237. if @newDdlValue is null
  238. begin
  239. EXEC proc_errorHandler 1, 'Please enter valid account number!', @tranId
  240. return
  241. end
  242. update remitTran SET
  243. accountNo = @newDdlValue
  244. WHERE id = @tranId
  245. SET @message = 'Account Number:'+ isnull(@oldValue,'')+' has been changed to '+isnull(@newDdlValue,'')
  246. insert into tranModifyLog(tranId,message,createdBy,createdDate,MsgType)
  247. select @tranId,@message,@user,dbo.FNAGetDateInNepalTZ(),'M'
  248. END
  249. ELSE IF @fieldName='BankName'
  250. BEGIN
  251. if @bankNewName is null
  252. begin
  253. EXEC proc_errorHandler 1, 'Please enter valid bank name!', @tranId
  254. return
  255. end
  256. if @branchNewName is null
  257. begin
  258. EXEC proc_errorHandler 1, 'Please enter valid bank name!', @tranId
  259. return
  260. end
  261. update remitTran SET
  262. pBank = @bankNewName,
  263. pBankName=dbo.GetAgentNameFromId(@bankNewName),
  264. pBankBranch = @branchNewName,
  265. pBankBranchName=dbo.GetAgentNameFromId(@branchNewName)
  266. WHERE id = @tranId
  267. SET @message = 'Bank Name:'+ isnull(@oldValue,'')+' has been changed to '+isnull(dbo.GetAgentNameFromId(@bankNewName),'')
  268. insert into tranModifyLog(tranId,message,createdBy,createdDate,MsgType)
  269. select @tranId,@message,@user,dbo.FNAGetDateInNepalTZ(),'M'
  270. DECLARE @message2 VARCHAR(200) = NULL
  271. SET @message2 = 'Branch name has been changed to '+isnull(dbo.GetAgentNameFromId(@branchNewName),'')
  272. insert into tranModifyLog(tranId,message,createdBy,createdDate,MsgType)
  273. select @tranId,@message2,@user,dbo.FNAGetDateInNepalTZ(),'M'
  274. END
  275. ELSE IF @fieldName='BranchName'
  276. BEGIN
  277. if @newDdlValue is null
  278. begin
  279. EXEC proc_errorHandler 1, 'Please enter valid branch name!', @tranId
  280. return
  281. end
  282. update remitTran SET
  283. pBankBranch = @newDdlValue,
  284. pBankBranchName=dbo.GetAgentNameFromId(@newDdlValue)
  285. WHERE id = @tranId
  286. SET @message = 'Branch Name:'+ isnull(@oldValue,'')+' has been changed to '+isnull(dbo.GetAgentNameFromId(@newDdlValue),'')
  287. insert into tranModifyLog(tranId,message,createdBy,createdDate,MsgType)
  288. select @tranId,@message,@user,dbo.FNAGetDateInNepalTZ(),'M'
  289. END
  290. ELSE IF @fieldName='pBranchName'
  291. BEGIN
  292. --EXEC [proc_modifyTXN] @flag = 'u', @user = 'admin', @tranId = '44', @fieldName = 'pBranchName', @oldValue = null, @newDdlValue = '3826'
  293. if @newDdlValue is null
  294. begin
  295. EXEC proc_errorHandler 1, 'Please enter valid branch name!', @tranId
  296. return
  297. end
  298. declare @parentId as int,
  299. @branchName as varchar(200),
  300. @agentName as varchar(200),
  301. @locationCode as int,
  302. @locationName as varchar(200),
  303. @oldLocation as varchar(200),
  304. @oldAgentId as int,
  305. @oldAgentName as varchar(200),
  306. @supAgentId as int,
  307. @supAgentName as varchar(200)
  308. select @locationCode=agentLocation from agentMaster where agentId=@newDdlValue
  309. select @locationName=districtName from api_districtList where districtCode=@locationCode
  310. select @oldLocation=districtName from api_districtList where districtCode=(select pLocation from remitTran where id=@tranId)
  311. select @oldAgentId= case when isnull(pAgent,0)=isnull(pBranch,0) then pSuperAgent else pAgent end
  312. from remitTran where id=@tranId
  313. select @oldAgentName=agentName from agentMaster where agentId=@oldAgentId
  314. if exists(select actAsBranch from agentMaster where agentId=@newDdlValue and actAsBranch='y')
  315. begin
  316. -- ## branch name
  317. select @branchName=agentName
  318. from agentMaster
  319. where agentId=@newDdlValue
  320. -- ## super agent
  321. select @supAgentId=parentId
  322. from agentMaster where agentId=@newDdlValue
  323. select @supAgentName=agentName
  324. from agentMaster where agentId=@supAgentId
  325. -- ## update if agent act as a branch
  326. update remitTran SET
  327. pAgent = @newDdlValue,
  328. pBranch=@newDdlValue,
  329. pAgentName=@branchName,
  330. pBranchName=@branchName,
  331. pLocation=@locationCode,
  332. pSuperAgent=@supAgentId,
  333. pSuperAgentName=@supAgentName
  334. WHERE id = @tranId
  335. -- ## update transaction log
  336. insert into tranModifyLog(tranId,message,createdBy,createdDate,MsgType)
  337. select @tranId,'Branch Name:'+ isnull(@oldValue,'')+' has been changed to '+isnull(@branchName,''),@user,dbo.FNAGetDateInNepalTZ(),'M'
  338. insert into tranModifyLog(tranId,message,createdBy,createdDate,MsgType)
  339. select @tranId,'Agent Name:'+ isnull(@oldAgentName,'')+' has been changed to '+isnull(@supAgentName,''),@user,dbo.FNAGetDateInNepalTZ(),'M'
  340. insert into tranModifyLog(tranId,message,createdBy,createdDate,MsgType)
  341. select @tranId,'Location Name:'+ isnull(@oldLocation,'')+' has been changed to '+isnull(@locationName,''),@user,dbo.FNAGetDateInNepalTZ(),'M'
  342. end
  343. else
  344. begin
  345. -- ## branch name & agent name
  346. select @parentId=parentId,@branchName=agentName
  347. from agentMaster
  348. where agentId=@newDdlValue
  349. select @agentName=agentName
  350. from agentMaster
  351. where agentId=@parentId
  352. -- ## super agent
  353. select @supAgentId=parentId
  354. from agentMaster where agentId=@parentId
  355. select @supAgentName=agentName
  356. from agentMaster where agentId=@supAgentId
  357. -- ## update remitTran
  358. update remitTran SET
  359. pAgent = @parentId,
  360. pBranch=@newDdlValue,
  361. pAgentName=@agentName,
  362. pBranchName=@branchName,
  363. pLocation=@locationCode,
  364. pSuperAgent=@supAgentId,
  365. pSuperAgentName=@supAgentName
  366. WHERE id = @tranId
  367. -- ## update transaction log
  368. insert into tranModifyLog(tranId,message,createdBy,createdDate,MsgType)
  369. select @tranId,'Branch Name:'+ isnull(@oldValue,'')+' has been changed to '+isnull(@branchName,''),@user,dbo.FNAGetDateInNepalTZ(),'M'
  370. insert into tranModifyLog(tranId,message,createdBy,createdDate,MsgType)
  371. select @tranId,'Agent Name:'+ isnull(@oldAgentName,'')+' has been changed to '+isnull(@agentName,''),@user,dbo.FNAGetDateInNepalTZ(),'M'
  372. insert into tranModifyLog(tranId,message,createdBy,createdDate,MsgType)
  373. select @tranId,'Location Name:'+ isnull(@oldLocation,'')+' has been changed to '+isnull(@locationName,''),@user,dbo.FNAGetDateInNepalTZ(),'M'
  374. end
  375. END
  376. ELSE IF @fieldName='stdName'
  377. BEGIN
  378. if @newTxtValue is null
  379. begin
  380. EXEC proc_errorHandler 1, 'Please enter valid Student Name!', @tranId
  381. return
  382. end
  383. update tranReceivers SET
  384. stdName = @newTxtValue
  385. WHERE tranId = @tranId
  386. SET @message = 'Student Name :'+ isnull(@oldValue,'')+' has been changed to '+isnull(@newTxtValue,'')
  387. insert into tranModifyLog(tranId,message,createdBy,createdDate,MsgType)
  388. select @tranId,@message,@user,dbo.FNAGetDateInNepalTZ(),'M'
  389. end
  390. ELSE IF @fieldName='stdLevel'
  391. BEGIN
  392. if @newDdlValue is null
  393. begin
  394. EXEC proc_errorHandler 1, 'Please enter valid Student Class/Level!', @tranId
  395. return
  396. end
  397. update tranReceivers SET
  398. stdLevel = @newDdlValue
  399. WHERE tranId = @tranId
  400. select @newDdlValue = name from schoolLevel with(nolock) where rowId = @newDdlValue
  401. SET @message = 'Student Class/Level:'+ isnull(@oldValue,'')+' has been changed to '+isnull(@newDdlValue,'')
  402. insert into tranModifyLog(tranId,message,createdBy,createdDate,MsgType)
  403. select @tranId,@message,@user,dbo.FNAGetDateInNepalTZ(),'M'
  404. end
  405. ELSE IF @fieldName='stdRollRegNo'
  406. BEGIN
  407. if @newTxtValue is null
  408. begin
  409. EXEC proc_errorHandler 1, 'Please enter valid Student Reg. No./Roll No.!', @tranId
  410. return
  411. end
  412. update tranReceivers SET
  413. stdRollRegNo = @newTxtValue
  414. WHERE tranId = @tranId
  415. SET @message = 'Student Reg. No./Roll No.:'+ isnull(@oldValue,'')+' has been changed to '+isnull(@newTxtValue,'')
  416. insert into tranModifyLog(tranId,message,createdBy,createdDate,MsgType)
  417. select @tranId,@message,@user,dbo.FNAGetDateInNepalTZ(),'M'
  418. end
  419. ELSE IF @fieldName='stdSemYr'
  420. BEGIN
  421. if @newDdlValue is null
  422. begin
  423. EXEC proc_errorHandler 1, 'Please enter valid Student Semester/Year!', @tranId
  424. return
  425. end
  426. update tranReceivers SET
  427. stdRollRegNo = @newDdlValue
  428. WHERE tranId = @tranId
  429. SET @message = 'Student Semester/Year:'+ isnull(@oldValue,'')+' has been changed to '+isnull(dbo.FNAGetDataValue(@newDdlValue),'')
  430. insert into tranModifyLog(tranId,message,createdBy,createdDate,MsgType)
  431. select @tranId,@message,@user,dbo.FNAGetDateInNepalTZ(),'M'
  432. end
  433. ELSE IF @fieldName='feeTypeId'
  434. BEGIN
  435. if @newDdlValue is null
  436. begin
  437. EXEC proc_errorHandler 1, 'Please enter valid Fee Type!', @tranId
  438. return
  439. end
  440. update tranReceivers SET
  441. feeTypeId = @newDdlValue
  442. WHERE tranId = @tranId
  443. select @newDdlValue = feeType from schoolFee with(nolock) where rowId = @newDdlValue
  444. SET @message = 'Fee Type :'+ isnull(@oldValue,'')+' has been changed to '+isnull(@newDdlValue,'')
  445. insert into tranModifyLog(tranId,message,createdBy,createdDate,MsgType)
  446. select @tranId,@message,@user,dbo.FNAGetDateInNepalTZ(),'M'
  447. end
  448. EXEC proc_errorHandler 0, 'Record has been updated successfully.', @tranId
  449. IF (ISNULL(@isAPI, 'N') = 'Y')
  450. BEGIN
  451. IF(@fieldName = 'pAgentLocation')
  452. BEGIN
  453. EXEC proc_modifyTxnAPI @flag = 'mpl', @controlNo = @controlNo, @user = @user, @newPLocation = @newDdlValue, @agentRefId = NULL
  454. END
  455. ELSE
  456. BEGIN
  457. EXEC proc_addCommentAPI @flag = 'i', @controlNo = @controlNo, @user = @user, @message = @message, @agentRefId = NULL
  458. END
  459. END
  460. END
  461. IF @flag='sa'
  462. BEGIN
  463. SELECT pBank FROM remitTran WHERE id=@tranId
  464. END
  465. END TRY
  466. BEGIN CATCH
  467. IF @@TRANCOUNT > 0
  468. ROLLBACK TRANSACTION
  469. DECLARE @errorMessage VARCHAR(MAX)
  470. SET @errorMessage = ERROR_MESSAGE()
  471. EXEC proc_errorHandler 1, @errorMessage, @tranId
  472. END CATCH
  473. GO