
/****** Object:  View [dbo].[ViwAccWarehouseDaysEnd]    Script Date: 10/24/2023 11:09:23 ق.ظ ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


ALTER VIEW [dbo].[ViwAccWarehouseDaysEnd]
AS
	SELECT m.[InOROut]
           ,m.[Number]
           ,m.[UserNumber] as MainUserNumber
           ,m.[Date]
           ,m.[WarehouseID] as Warehouse
           ,m.[PersonTotalID]
           ,m.[PersonControlID]
           ,m.[PersonDetailID1]
           ,m.[PersonDetailID2]
           ,m.[Description] as MainDescription
           ,m.[UpdateDate] as MainUpdateDate
           ,m.[Updater]
           ,m.[WarehouseIDTo]
           ,m.[FormID]
           ,m.[FromForm]
           ,m.[OutID]
           ,m.[Takhfif] as MainTakhfif
           ,m.[HamlAndOther]
           ,m.[TakhfifDocItemID]
           ,m.[TakhfifDocHeaderID]
           ,m.[HamlDocItemID]
           ,m.[HamlDocHeaderID]
           ,m.[CostCenter]
           ,m.[Project]
           ,m.[Flags], s.*, Round(DATEDIFF(Day, GETDATE(), DATEADD(Day, [Time], Date)),0,1) AS DaysEnd
	FROM ViwAccWarehouseDetails as s left outer join AccWarehouse as m on m.id=s.WarehouseID 
	where [Time]>0
        
GO

