IF OBJECT_ID('V_PARCIAL_RECEBIMENTOS') IS NOT NULL 
	DROP VIEW V_PARCIAL_RECEBIMENTOS
GO

CREATE VIEW V_PARCIAL_RECEBIMENTOS
AS
SELECT	SUM(CARTAO) AS CARTAO
		,SUM(CHEQUE) AS CHEQUE
		,SUM(CONVENIO) AS CONVENIO
		,SUM(PBM) AS PBM
		,SUM(DESCONTO) AS DESCONTO
		,SUM(DINHEIRO) AS DINHEIRO
		,SUM(DUPLICATA) AS DUPLICATA
		,SUM(DEVOLUCAO) AS DEVOLUCAO
		,SUM(TICKETS) AS TICKETS
FROM (
SELECT	SUM(VLR_CARTAO) AS CARTAO
		,SUM(VLR_CHQS) AS CHEQUE
		,SUM(VLR_CONV) AS CONVENIO
		,SUM(VLR_CONV_PBM) AS PBM
		,SUM(VLR_DESC + VLR_DESC_ITENS) AS DESCONTO
		,SUM(VLR_DINH) AS DINHEIRO
		,SUM(VLR_DUP) AS DUPLICATA
		,SUM(VLR_NCC) AS DEVOLUCAO
		,SUM(VLR_TICKETS) AS TICKETS
FROM	PDV_VD
WHERE	DT_VD = CONVERT(VARCHAR,GETDATE(),112) AND ST_VD = 0
UNION  
SELECT	SUM(VLR_CARTAO) AS CARTAO
		,0 AS CHEQUE
		,0 AS CONVENIO
		,0 AS PBM
		,0 AS DESCONTO
		,SUM(VLR_DINH) AS DINHEIRO
		,0 AS DUPLICATA
		,0 AS DEVOLUCAO
		,0 AS TICKETS
FROM	PDV_CUPOM_NAO_FISCAL
WHERE	DT_CUPOM = CONVERT(VARCHAR,GETDATE(),112) AND TP_CUPOM_NAO_FISCAL = 3
)	TMP