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.

114 lines
7.0 KiB

1 year ago
  1. USE [FastMoneyPro_Remit]
  2. GO
  3. /****** Object: StoredProcedure [dbo].[proc_internationalSend] 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_internationalSend @flag='cal',@agentId='3885',@collCurrency='MYR',@payCountryId='104',@payCorrency='INR',@tranType='1',@amount='1200'
  10. EXEC proc_internationalSend @flag = 'fee', @agentId = '3885', @pCountry = '151', @cCurrency = 'MYR',
  11. @ExRate = '24.137074', @tranType = '1', @sendAmount = '300000', @recAmount = null, @user = 'admin'
  12. */
  13. CREATE proc [dbo].[proc_internationalSend]
  14. @flag VARCHAR(50) = NULL
  15. ,@user VARCHAR(30) = NULL
  16. ,@agentId INT = NULL
  17. ,@cCurrency VARCHAR(30) = NULL
  18. ,@pCountry INT = NULL
  19. ,@pCurrency VARCHAR(50) = NULL
  20. ,@tranType INT = NULL
  21. ,@sendAmount FLOAT = NULL
  22. ,@recAmount FLOAT = NULL
  23. ,@ExRate FLOAT = NULL
  24. ,@sMemberId VARCHAR(50) = NULL
  25. ,@sFName VARCHAR(200) = NULL
  26. ,@sMName VARCHAR(200) = NULL
  27. ,@sLName VARCHAR(200) = NULL
  28. ,@sMobile VARCHAR(200) = NULL
  29. ,@sDOB VARCHAR(200) = 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 @table AS VARCHAR(MAX), @ServiceCharge AS FLOAT
  36. IF @flag = 'a'
  37. BEGIN
  38. SELECT a.currencyId,b.currencyCode FROM agentCurrency a WITH(NOLOCK)
  39. INNER JOIN currencyMaster b WITH(NOLOCK) ON a.currencyId=b.currencyId
  40. WHERE agentId=@agentId
  41. END
  42. IF @flag = 'exRate'
  43. BEGIN
  44. IF @recAmount =0
  45. SET @recAmount=NULL
  46. IF @sendAmount =0
  47. SET @sendAmount=NULL
  48. SELECT CAST(ISNULL(customerCrossRate, 0) AS DECIMAL(11, 6)) ExRate
  49. FROM dbo.FNAGetExRateForTran(@agentId, NULL, @pCountry, @cCurrency, @pCurrency,@tranType,@user)
  50. END
  51. IF @flag = 'fee'
  52. BEGIN
  53. IF @recAmount =0
  54. SET @recAmount=NULL
  55. IF @sendAmount =0
  56. SET @sendAmount=NULL
  57. IF @recAmount IS NULL AND @sendAmount IS NOT NULL
  58. BEGIN
  59. SELECT @ServiceCharge=ISNULL(amount,0) FROM [dbo].FNAGetSC(@agentId, NULL, @pCountry, NULL, NULL ,@tranType, @sendAmount, @cCurrency)
  60. SELECT '<font color=''red''><b>'+CAST(ISNULL(@ServiceCharge,'0.00') AS VARCHAR)+'</b></font>' ServiceCharge
  61. ,'<font color=''red''><b>'+dbo.ShowDecimal(@sendAmount*@ExRate+@ServiceCharge)+'</b></font>' [cAmount]
  62. ,dbo.ShowDecimalExceptComma(@sendAmount) sendAmount
  63. ,dbo.ShowDecimalExceptComma(@sendAmount*@ExRate) recAmount
  64. END
  65. IF @recAmount IS NOT NULL AND @sendAmount IS NULL
  66. BEGIN
  67. SET @sendAmount =@recAmount/@ExRate
  68. SELECT @ServiceCharge=ISNULL(amount,0) FROM [dbo].FNAGetSC(@agentId, NULL, @pCountry, NULL, NULL ,@tranType, @sendAmount, @cCurrency)
  69. SELECT '<font color=''red''><b>'+CAST(ISNULL(@ServiceCharge,'0.00') AS VARCHAR)+'</b></font>' ServiceCharge
  70. ,'<font color=''red''><b>'+dbo.ShowDecimal(@ExRate*@sendAmount+@ServiceCharge)+'</b></font>' [cAmount]
  71. ,dbo.ShowDecimalExceptComma(@sendAmount) sendAmount
  72. ,dbo.ShowDecimalExceptComma(@recAmount) recAmount
  73. END
  74. END
  75. IF @flag=''
  76. BEGIN
  77. SELECT * FROM customers WHERE membershipId=@sMemberId
  78. END
  79. END TRY
  80. BEGIN CATCH
  81. IF @@TRANCOUNT > 0
  82. ROLLBACK TRANSACTION
  83. DECLARE @errorMessage VARCHAR(MAX)
  84. SET @errorMessage = ERROR_MESSAGE()
  85. EXEC proc_errorHandler 1, @errorMessage, @user
  86. END CATCH
  87. GO