USE [DD_ECM]
GO

/****** Object:  View [dbo].[VWCUST_EB2B_CREATED]    Script Date: 21.03.2024 16:58:20 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE VIEW [dbo].[VWCUST_EB2B_CREATED] as 
SELECT
	ba.dwDocID as DOC_ID,
	'STANDARD' as Outputfilename,
	CAST(CAST(ba.dwCreationDate as CHAR(10)) as DATE) as CreationDate
FROM 
	windream60.dbo.BaseAttributes ba LEFT JOIN TBCUST_PM_RPT_CREATED REF ON ba.dwDocID = REF.DocID
WHERE 
	DATEPART(YEAR,CAST(CAST(ba.dwCreationDate as CHAR(10)) as DATE)) > 2022 AND
	--ba.dwDocID in (741833,740744) AND
	ba.sztext37 = 'Eingangsrechnung' AND
	ba.szText33 = 'erledigt' AND
	ba.szFile_Ext = '.PDF' AND
	ba.dwDate04 is not null AND
	LEFT(ba.szLongName,6) = 'ERE_ER' AND
	REF.DocID IS NULL
GO


