USE [FastMoneyPro_Remit]
GO
/****** Object:  StoredProcedure [dbo].[proc_TransactionCount]    Script Date: 7/4/2019 11:35:48 AM ******/
DROP PROCEDURE [dbo].[proc_TransactionCount]
GO
/****** Object:  StoredProcedure [dbo].[proc_TransactionCount]    Script Date: 7/4/2019 11:35:48 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
 
 CREATE proc [dbo].[proc_TransactionCount] 
 as
 declare @date date = GetDate() ;

 declare @intPaid int , @iSend int , @iCancel int 

	SELECT @intPaid = COUNT(tranStatus) 
	FROM dbo.remitTran WITH(NOLOCK)
	WHERE paidDate BETWEEN @date AND GETDATE() 

	SELECT @iSend = COUNT('A') 
	FROM dbo.remitTran  WITH(NOLOCK)
	WHERE createdDate BETWEEN @date AND GETDATE()

	SELECT @iCancel = COUNT('A') 
	FROM dbo.remitTran  WITH(NOLOCK)
	WHERE cancelApprovedDate BETWEEN @date AND GETDATE()

 SELECT @iCancel iCancel,@iSend iSend, @intPaid intPaidCount


 SELECT [TxnNo] = count(1) ,tranStatus
 FROM remitTran(nolock) 
 where tranStatus NOT IN ('payment','cancel','Paid')
 group by tranStatus
 UNION ALL

SELECT [TxnNo] = count(1),'Pending GIBL Reprocessing' tranStatus
FROM remitTran trn WITH(NOLOCK)
WHERE trn.approvedBy IS NOT NULL AND trn.payStatus = 'Unpaid'
AND tranStatus = 'payment' AND pCountry = 'Nepal'
AND trn.pAgent = 1056
GO
