/****** Object:  View [dbo].[V_PAINEL_NFE_EST_PED_VD_PRE_FATURA_ANALITICO]    Script Date: 03/10/2018 11:00:00 ******/ 
IF EXISTS (SELECT * 
           FROM   SYS.VIEWS 
           WHERE  OBJECT_ID = 
      Object_id(N'[dbo].[V_PAINEL_NFE_EST_PED_VD_PRE_FATURA_ANALITICO]')) 
  DROP VIEW [dbo].[V_PAINEL_NFE_EST_PED_VD_PRE_FATURA_ANALITICO] 

GO 

--SELECT * FROM V_PAINEL_NFE_EST_PED_VD_PRE_FATURA_ANALITICO 
CREATE VIEW V_PAINEL_NFE_EST_PED_VD_PRE_FATURA_ANALITICO  
AS
SELECT CD_FILIAL AS filialOrigemId,
       CD_PED AS numeroPedido,
       CASE
           WHEN CD_FIL_DEST >0 THEN CD_FIL_DEST
           ELSE CD_CLI
       END AS filialDestinoId,
       NM_FANT AS filialDestinoNome,
       DT_EMI_PED AS data,
       VLR_TOT_PED AS valor,
       STS_PED AS status,
       CD_RESSUP AS ressuprimentoNumero
FROM V_EST_PED_VD
WHERE DT_EMI_PED = CONVERT(CHAR(10), GETDATE(), 112)