/****** Object:  View [dbo].[ViwAccWarehouseDetailsPhase2]    Script Date: 23/01/1402 02:50:47 ب.ظ ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

ALTER VIEW [dbo].[ViwAccWarehouseDetailsPhase2]
AS
SELECT     V1.ID, V1.WarehouseID, V1.Request, V1.NetPrice, 
                      V1.TotalPrice, V1.RequestUnit, V1.UnitName, 
                      COALESCE (V1.OrderTitle, D.Title, C.Title, T.Title, V1.OrderTitle) AS OrderTitle, 
                      V1.OrderTotalID, V1.OrderControlID, V1.OrderDetailID1, 
                      V1.OrderDetailID2, V1.DocItemID, V1.DocHeaderID, 
                      V1.Status, CAST(0 AS bit) AS Selected, V1.UsedDocNumber, V1.DocNumber, 
                      V1.OtherTotalID, V1.OtherControlID, V1.OtherDetailID1, 
                      V1.OtherDetailID2, V1.Value2, V1.Unit2, V1.Unit2Name, 
                      V1.SerialFrom, V1.SerialTo, V1.Oft, V1.Routobat, 
                      V1.OftPayeh, V1.RoutobatPayeh, V1.RequestPayeh, 
                      V1.Time, V1.Description, V1.UserNumber, V1.Haml, 
                      V1.Takhfif, V1.PrdDate, V1.ExpDate, V1.WarehouseNo, 
                      V1.SFKeshti, V1.SFMojavez, V1.SFTonaj, V1.SFBarbari, 
                      V1.SFMabda, V1.SFCommision, V1.SFAnbarStart, 
                      V1.SFAnbarEnd1, V1.SFAnbarEnd2, V1.SFAfzayeshType, 
                      V1.SFAfzayesh1, V1.SFAfzayesh2, V1.SFSarak, V1.VRequest, V1.VDate, V1.VUpdater,
					  V1.Maliat, V1.Avarez
FROM         dbo.AccDetail as D WITH (NOLOCK) RIGHT OUTER JOIN
                      dbo.ViwAccWarehouseDetailsPhase1 as V1 ON D.ID = V1.OrderDetailID1 LEFT OUTER JOIN
                      dbo.AccControl as C ON V1.OrderControlID = C.ID LEFT OUTER JOIN
                      dbo.AccTotal as T ON V1.OrderTotalID =T.ID
GO


