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

CREATE VIEW V_MOVIMENTO_OPERADOR AS
SELECT	MOV.CD_EMP,MOV.CD_FILIAL,MOV.CD_CX,MOV.CD_MOV,MOV.DT_MOV
	,MOV.CD_MOV_PDV,MOV.ST_MOV,MOV.VL_ABERT AS VLR_ABERTURA
	,MOV.CD_OPER,OPER.NM_USU AS NM_OPER
	,0 AS CD_OPER_FECHA,NULL AS NM_OPER_FECHA
	,CASE WHEN COALESCE(FECHA.CD_MOV,0) = 0 THEN 0 ELSE 1 END AS MOVIMENTO_FECHADO
	,FECHA.TP_FORMA_PGTO AS TP_PGTO,FECHA.CD_IT
	,FECHA.VLR_PGTO AS VLR_PGTO_CALC,FECHA.VLR_DIGITADO AS VLR_PGTO_INFO
FROM 	PDV_MOV_DIARIO_OPERADOR MOV
LEFT	JOIN PDV_MOV_DIARIO_OPERADOR_FECHAMENTO FECHA ON MOV.CD_EMP = FECHA.CD_EMP AND MOV.CD_FILIAL = FECHA.CD_FILIAL AND MOV.CD_CX = FECHA.CD_CX AND MOV.CD_MOV = FECHA.CD_MOV
LEFT	JOIN GLB_USU OPER ON MOV.CD_OPER = OPER.CD_USU