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.

65 lines
2.8 KiB

1 year ago
  1. USE [FastMoneyPro_Remit]
  2. GO
  3. /****** Object: StoredProcedure [dbo].[proc_cancelApi] Script Date: 9/27/2019 1:30:14 PM ******/
  4. SET ANSI_NULLS ON
  5. GO
  6. SET QUOTED_IDENTIFIER ON
  7. GO
  8. CREATE proc [dbo].[proc_cancelApi]
  9. (
  10. @flag VARCHAR(50)
  11. ,@controlNo VARCHAR(20) = NULL
  12. ,@user VARCHAR(100) = NULL
  13. )
  14. AS
  15. SET NOCOUNT ON
  16. SET XACT_ABORT ON
  17. DECLARE
  18. @controlNoEncrypted VARCHAR(50)
  19. ,@tranStatus VARCHAR(50)
  20. ,@message VARCHAR(MAX)
  21. ,@pCountry VARCHAR(100)
  22. SELECT @controlNoEncrypted = dbo.FNAEncryptString(UPPER(LTRIM(RTRIM(@controlNo))))
  23. IF @flag = 'chkStatus'
  24. BEGIN
  25. IF @user IS NULL
  26. BEGIN
  27. EXEC proc_errorHandler 1, 'Your session has expired. Cannot cancel transaction', NULL
  28. RETURN
  29. END
  30. SELECT
  31. @tranStatus = tranStatus
  32. ,@pCountry = pCountry
  33. FROM dbo.remitTran WITH(NOLOCK) WHERE controlNo = @controlNoEncrypted
  34. IF (@tranStatus IS NULL)
  35. BEGIN
  36. EXEC proc_errorHandler 1, 'Transaction not found', @controlNoEncrypted
  37. RETURN
  38. END
  39. IF @tranStatus = 'Paid' AND @pCountry = 'Nepal'
  40. BEGIN
  41. set @message = 'Transaction is in PAID status, so can not approve the cancel request.'
  42. EXEC proc_errorHandler 1, @message, @controlNoEncrypted
  43. RETURN
  44. END
  45. EXEC [proc_errorHandler] 0, 'Healthy', @controlNoEncrypted
  46. END
  47. IF @flag = 'update'
  48. BEGIN
  49. EXEC [proc_errorHandler] 0, 'Successfully updated', @controlNoEncrypted
  50. END
  51. GO