SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO
CREATE VIEW [transform].[current_date_Prognose]
AS
SELECT [Bundeslaender Id]
     , [Datum] as [Invoice Date]
     , [Wochentage Id]
     , [Arbeitstag Mofr]
     , [Zaehler Mofr]
     , [Summe Mofr]
     , [Arbeitstag Mosa]
     , [Zaehler Mosa]
     , [Summe Mosa]
     , [Feiertage Id]
     , [Jahr]
     , iif([Config].[mosa_fibu] = 'J', [Arbeitstag Nr Jahr Mosa], [Arbeitstag Nr Jahr Mofr]) AS "Arbeitstag Nr Jahr"
     , iif([Config].[mosa_fibu] = 'J', [Gesamt Arbeitstage Mosa], [Gesamt Arbeitstage Mofr]) AS "Gesamt Arbeitstage"
     , [Tag_Dashboard]
     , [Monat_Dashboard]
     , [Jahr_Dashboard]
FROM [transform_imr].[Arbeitstage]
         CROSS JOIN [data].[GC_Config_Pivot] [Config]
WHERE [Bundeslaender Id] = [Config].[bundeslaender_id]
  AND ([Arbeitstag Mofr] = 1 OR ([Config].[mosa_fibu] = 'J' AND [Arbeitstag Mosa] = 1) OR [Feiertage Id] = 23)
  AND [Jahr] = year(getdate())
  AND [Arbeitstage].[Datum] <= (getdate() - 1)
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO

GO
