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

GO
 
--SELECT * FROM V_PAINEL_NFE_DANFE_IMPORTADO_QTDE	WITH (NOLOCK)
CREATE VIEW [dbo].[V_PAINEL_NFE_DANFE_IMPORTADO_QTDE] AS
SELECT COUNT(1) AS QTDE_DANFE_IMPORTADO
FROM EST_NF_ENT_DANFE_PROVISORIO
INNER JOIN EST_NF_ENT_DANFE_PROVISORIO_PENDENTE ON EST_NF_ENT_DANFE_PROVISORIO.CD_CTR = EST_NF_ENT_DANFE_PROVISORIO_PENDENTE.CD_CTR
INNER JOIN EST_NF_ENT_NFE_FORN_VALID ON EST_NF_ENT_DANFE_PROVISORIO.CD_EMP = EST_NF_ENT_NFE_FORN_VALID.CD_EMP
AND EST_NF_ENT_DANFE_PROVISORIO.CD_FILIAL = EST_NF_ENT_NFE_FORN_VALID.CD_FILIAL
AND EST_NF_ENT_DANFE_PROVISORIO.NR_NF = EST_NF_ENT_NFE_FORN_VALID.NR_NF
AND EST_NF_ENT_DANFE_PROVISORIO.CD_FORN = EST_NF_ENT_NFE_FORN_VALID.CD_FORN
WHERE VALIDACAO IN (1, 4)