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

USE [FastMoneyPro_Remit]
GO
/****** Object: StoredProcedure [dbo].[proc_SchedulerForRemittanceVoucher] Script Date: 9/27/2019 1:30:14 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE proc [dbo].[proc_SchedulerForRemittanceVoucher]
as
set nocount on
select DISTINCT field1,ref_num,acct_type_code into #acc
from FastMoneyPro_Account.DBO.tran_master(nolock) where field2='remittance voucher' ----and acc_num='771345592'
and acct_type_code is null and tran_date >=DATEADD(DAY,-2,cast(getdate() as date))
--and acc_num in (
--select acc_num from FastMoneyPro_Account.DBO.ac_master(nolock) where agent_id in (
--select agentId from FastMoneyPro_Remit.dbo.agentmaster(nolock) where isApiPartner=1 and agenttype=2903
-- union
-- select 1056
-- --union
-- --select 1036
--) and acct_rpt_code='TC'
--)
--select * from ac_master(nolock) where acct_name like '%tranglo%'
select controlNo=dbo.FNADecryptString(controlNo),pagent,pagentName,approveddate,pcountry,pagentcomm into #temp
from FastMoneyPro_Remit.dbo.remittran(nolock) where
approveddate BETWEEN DATEADD(DAY,-2,cast(getdate() as date)) AND DATEADD(MINUTE,-2,GETDATE())
--and pagent in (
-- select agentId from FastMoneyPro_Remit.dbo.agentmaster(nolock) where isApiPartner=1 and agenttype=2903
-- union
-- select 1056 union
-- select 1036
--)
--select 'exec proc_transactionVoucherEntry '''+controlNo+'''' from #temp t where pcountry <> 'Cambodia'
--select * from #temp t
--inner join #acc c on c.field1 = t.controlNo
delete t from #temp t
inner join #acc c on c.field1 = t.controlNo
select TOP 10 * into #RemainforVoucher from #temp
alter table #RemainforVoucher add id int IDENTITY(1,1)
declare @tRow int,@controlno varchar(20)
select @tRow = count(1) from #RemainforVoucher
--select * from #RemainforVoucher
--return
while @tRow>0
begin
select @controlno = controlNo from #RemainforVoucher where id = @tRow
EXEC FastMoneyPro_Account.DBO.proc_transactionVoucherEntry @controlno
WAITFOR DELAY '000:00:01'
set @tRow = @tRow -1
end
EXEC Proc_PayTXN_Locked_Released
SELECT TOP 5 * INTO #TempPaid FROM tblPostedTxnQueue(NOLOCK) WHERE acPost IS NULL
IF NOT EXISTS(SELECT 'A' FROM #TempPaid)
RETURN
ALTER TABLE #TempPaid ADD id int identity(1,1)
SET @tRow = 0
select @tRow = count(1) from #TempPaid
UPDATE T SET T.CONTROLNO=DBO.FNADecryptString(r.controlNo) FROM #TempPaid T
INNER JOIN remitTran R(NOLOCK) ON R.id = T.tranId
WHERE pCountry ='NEPAL' AND R.pAgent IS NOT NULL
DECLARE @pAgent BIGINT,@User VARCHAR(30),@tranId BIGINT
WHILE @tRow>0
BEGIN
SELECT @controlno = controlNo,@pAgent=pAgentId,@User=POSTEDBY,@tranId = tranId FROM #TempPaid WHERE id = @tRow
EXEc FastMoneyPro_Account.dbo.proc_remittanceVoucher_Paid @controlNo = @controlno ,@pAgent = @pAgent,@User = @User
WAITFOR DELAY '000:00:01'
SET @tRow = @tRow -1
UPDATE tblPostedTxnQueue SET acPost=1,controlno = @controlno WHERE tranId = @tranId
END
GO