/****** Object:  View [dbo].[ViwAccWarehouseDetailsPhase1]    Script Date: 23/01/1402 02:51:12 ب.ظ ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO



ALTER VIEW [dbo].[ViwAccWarehouseDetailsPhase1]
AS
SELECT     WD.ID, WD.WarehouseID, WD.OrderTotalID, WD.OrderControlID, 
                      WD.OrderDetailID1, WD.OrderDetailID2, WD.Request, WD.RequestUnit, 
                      WD.NetPrice, WD.TotalPrice, SmallLists_1.Title AS UnitName, dbo.AccDetail.Title AS OrderTitle, WD.DocItemID, 
                      WD.DocHeaderID, WD.Status, AccDocHeader_1.Number AS DocNumber, dbo.AccDocHeader.Number AS UsedDocNumber, 
                      WD.OtherTotalID, WD.OtherControlID, WD.OtherDetailID1, WD.OtherDetailID2, 
                      WD.Value2, WD.Unit2, dbo.SmallLists.Title AS Unit2Name, WD.SerialFrom, WD.SerialTo, 
                      WD.Oft, WD.Routobat, WD.OftPayeh, WD.RoutobatPayeh, WD.RequestPayeh, 
                      WD.Time, WD.Description, WD.UserNumber, WD.Haml, WD.Takhfif, 
                      WD.PrdDate, WD.ExpDate, W.WarehouseID as WarehouseNo, WD.SFKeshti, WD.SFMojavez, 
                      WD.SFTonaj, WD.SFBarbari, WD.SFMabda, WD.SFCommision, WD.SFAnbarStart, 
                      WD.SFAnbarEnd1, WD.SFAnbarEnd2, WD.SFAfzayeshType, WD.SFAfzayesh1, 
                      WD.SFAfzayesh2, WD.SFSarak, WD.VRequest, wd.VDate, wd.VUpdater,
					  WD.Maliat, WD.Avarez
FROM         dbo.SmallLists 
		RIGHT OUTER JOIN dbo.AccWarehouseDetails as WD WITH (NOLOCK) ON dbo.SmallLists.ID = WD.Unit2 
		LEFT OUTER JOIN dbo.AccDocHeader AS AccDocHeader_1 ON WD.DocHeaderID = AccDocHeader_1.ID 
		LEFT OUTER JOIN dbo.AccDocItem 
		INNER JOIN dbo.AccDocHeader ON dbo.AccDocItem.HeaderID = dbo.AccDocHeader.ID ON WD.DocItemID = dbo.AccDocItem.ID 
		LEFT OUTER JOIN dbo.AccDetail ON WD.OrderDetailID2 = dbo.AccDetail.ID 
		LEFT OUTER JOIN dbo.SmallLists AS SmallLists_1 ON WD.RequestUnit = SmallLists_1.ID
		left outer join AccWarehouse W on wd.WarehouseID = W.id
GO


