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.

49 lines
2.0 KiB

1 year ago
  1. USE [FastMoneyPro_Remit]
  2. GO
  3. /****** Object: StoredProcedure [dbo].[proc_updateCancelTopUpLimit] 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. */
  10. CREATE proc [dbo].[proc_updateCancelTopUpLimit]
  11. @agentId INT
  12. ,@amount MONEY
  13. AS
  14. SET NOCOUNT ON
  15. BEGIN
  16. DECLARE
  17. @glCode INT
  18. ,@topUpTillYesterday MONEY
  19. SET @glCode = 1
  20. SELECT
  21. @topUpTillYesterday = ISNULL(topUpTillYesterday, 0)
  22. FROM creditLimit WHERE agentId = @agentId
  23. IF (@topUpTillYesterday = 0)
  24. BEGIN
  25. UPDATE creditLimit SET
  26. todaysCancelled = ISNULL(todaysCancelled, 0) + ISNULL(@amount, 0)
  27. WHERE agentId = @agentId
  28. END
  29. ELSE
  30. BEGIN
  31. UPDATE creditLimit SET
  32. todaysCancelled = ISNULL(todaysCancelled, 0) + ISNULL(@amount, 0)
  33. ,topUpTillYesterday = CASE WHEN @topUpTillYesterday - ISNULL(@amount, 0) <= 0 THEN 0 ELSE @topUpTillYesterday - ISNULL(@amount, 0) END
  34. WHERE agentId = @agentId
  35. END
  36. END
  37. --select * from ac_master
  38. GO