IF OBJECT_ID('UFD_EXP_CTB_MOV_CAIXA_Z') IS NOT NULL
	BEGIN
		DROP FUNCTION UFD_EXP_CTB_MOV_CAIXA_Z
	END
	
GO 
   
  
CREATE FUNCTION UFD_EXP_CTB_MOV_CAIXA_Z(@CD_EMP		INT,
										@CD_FILIAL	INT,
										@DT_INI		DATETIME,
										@DT_FIM		DATETIME)		

RETURNS @RS_RETURN TABLE(
		CD_FILIAL			INT, 
		DT_VD				DATETIME, 
		VLR_DINH			MONEY, 
		VLR_CHQS			MONEY, 
		VLR_CARTAO			MONEY, 
		VLR_TICKETS			MONEY, 
		VLR_DUP				MONEY, 
		VLR_CONV			MONEY, 
		VLR_TROCO_CHQ		MONEY)

AS
BEGIN    
    
	INSERT INTO @RS_RETURN     
    SELECT 
		CD_FILIAL, 
		DT_VD, 
		VLR_DINH, 
		VLR_CHQS, 
		VLR_CARTAO, 
		VLR_TICKETS, 
		VLR_DUP, 
		VLR_CONV, 
		VLR_TROCO_CHQ
    FROM V_PDV_VD_RECBTO
    WHERE CD_EMP		= @CD_EMP
		AND CD_FILIAL	= @CD_FILIAL
		AND DT_VD		BETWEEN @DT_INI AND @DT_FIM

	RETURN
		
END		