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.

99 lines
5.9 KiB

1 year ago
  1. USE [FastMoneyPro_Remit]
  2. GO
  3. /****** Object: StoredProcedure [dbo].[proc_SchedulerForRemittanceVoucher] 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_SchedulerForRemittanceVoucher]
  9. as
  10. set nocount on
  11. select DISTINCT field1,ref_num,acct_type_code into #acc
  12. from FastMoneyPro_Account.DBO.tran_master(nolock) where field2='remittance voucher' ----and acc_num='771345592'
  13. and acct_type_code is null and tran_date >=DATEADD(DAY,-2,cast(getdate() as date))
  14. --and acc_num in (
  15. --select acc_num from FastMoneyPro_Account.DBO.ac_master(nolock) where agent_id in (
  16. --select agentId from FastMoneyPro_Remit.dbo.agentmaster(nolock) where isApiPartner=1 and agenttype=2903
  17. -- union
  18. -- select 1056
  19. -- --union
  20. -- --select 1036
  21. --) and acct_rpt_code='TC'
  22. --)
  23. --select * from ac_master(nolock) where acct_name like '%tranglo%'
  24. select controlNo=dbo.FNADecryptString(controlNo),pagent,pagentName,approveddate,pcountry,pagentcomm into #temp
  25. from FastMoneyPro_Remit.dbo.remittran(nolock) where
  26. approveddate BETWEEN DATEADD(DAY,-2,cast(getdate() as date)) AND DATEADD(MINUTE,-2,GETDATE())
  27. --and pagent in (
  28. -- select agentId from FastMoneyPro_Remit.dbo.agentmaster(nolock) where isApiPartner=1 and agenttype=2903
  29. -- union
  30. -- select 1056 union
  31. -- select 1036
  32. --)
  33. --select 'exec proc_transactionVoucherEntry '''+controlNo+'''' from #temp t where pcountry <> 'Cambodia'
  34. --select * from #temp t
  35. --inner join #acc c on c.field1 = t.controlNo
  36. delete t from #temp t
  37. inner join #acc c on c.field1 = t.controlNo
  38. select TOP 10 * into #RemainforVoucher from #temp
  39. alter table #RemainforVoucher add id int IDENTITY(1,1)
  40. declare @tRow int,@controlno varchar(20)
  41. select @tRow = count(1) from #RemainforVoucher
  42. --select * from #RemainforVoucher
  43. --return
  44. while @tRow>0
  45. begin
  46. select @controlno = controlNo from #RemainforVoucher where id = @tRow
  47. EXEC FastMoneyPro_Account.DBO.proc_transactionVoucherEntry @controlno
  48. WAITFOR DELAY '000:00:01'
  49. set @tRow = @tRow -1
  50. end
  51. EXEC Proc_PayTXN_Locked_Released
  52. SELECT TOP 5 * INTO #TempPaid FROM tblPostedTxnQueue(NOLOCK) WHERE acPost IS NULL
  53. IF NOT EXISTS(SELECT 'A' FROM #TempPaid)
  54. RETURN
  55. ALTER TABLE #TempPaid ADD id int identity(1,1)
  56. SET @tRow = 0
  57. select @tRow = count(1) from #TempPaid
  58. UPDATE T SET T.CONTROLNO=DBO.FNADecryptString(r.controlNo) FROM #TempPaid T
  59. INNER JOIN remitTran R(NOLOCK) ON R.id = T.tranId
  60. WHERE pCountry ='NEPAL' AND R.pAgent IS NOT NULL
  61. DECLARE @pAgent BIGINT,@User VARCHAR(30),@tranId BIGINT
  62. WHILE @tRow>0
  63. BEGIN
  64. SELECT @controlno = controlNo,@pAgent=pAgentId,@User=POSTEDBY,@tranId = tranId FROM #TempPaid WHERE id = @tRow
  65. EXEc FastMoneyPro_Account.dbo.proc_remittanceVoucher_Paid @controlNo = @controlno ,@pAgent = @pAgent,@User = @User
  66. WAITFOR DELAY '000:00:01'
  67. SET @tRow = @tRow -1
  68. UPDATE tblPostedTxnQueue SET acPost=1,controlno = @controlno WHERE tranId = @tranId
  69. END
  70. GO