/****** Object:  View [dbo].[ViwAccFactorDetailPhase2]    Script Date: 1/28/2024 08:19:14 ق.ظ ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

/*319*/
ALTER VIEW [dbo].[ViwAccFactorDetailPhase2]
AS
SELECT   dbo.ViwAccFactorDetailPhase1.ID, dbo.ViwAccFactorDetailPhase1.FactorID, dbo.ViwAccFactorDetailPhase1.Request, dbo.ViwAccFactorDetailPhase1.NetPrice, dbo.ViwAccFactorDetailPhase1.TotalPrice, 
                dbo.ViwAccFactorDetailPhase1.RequestUnit, dbo.ViwAccFactorDetailPhase1.UnitName, COALESCE (dbo.ViwAccFactorDetailPhase1.OrderTitle, dbo.AccDetail.Title, dbo.AccControl.Title, dbo.AccTotal.Title, dbo.ViwAccFactorDetailPhase1.OrderTitle) 
                AS OrderTitle, dbo.ViwAccFactorDetailPhase1.OrderTotalID, dbo.ViwAccFactorDetailPhase1.OrderControlID, dbo.ViwAccFactorDetailPhase1.OrderDetailID1, dbo.ViwAccFactorDetailPhase1.OrderDetailID2, dbo.ViwAccFactorDetailPhase1.DocItemID, 
                dbo.ViwAccFactorDetailPhase1.DocHeaderID, dbo.ViwAccFactorDetailPhase1.Status, CAST(0 AS bit) AS Selected, dbo.ViwAccFactorDetailPhase1.UsedDocNumber, dbo.ViwAccFactorDetailPhase1.DocNumber, 
                dbo.ViwAccFactorDetailPhase1.OtherTotalID, dbo.ViwAccFactorDetailPhase1.OtherControlID, dbo.ViwAccFactorDetailPhase1.OtherDetailID1, dbo.ViwAccFactorDetailPhase1.OtherDetailID2, dbo.ViwAccFactorDetailPhase1.Value2, 
                dbo.ViwAccFactorDetailPhase1.Unit2, dbo.ViwAccFactorDetailPhase1.Unit2Name, dbo.ViwAccFactorDetailPhase1.Discont, dbo.ViwAccFactorDetailPhase1.Maliat, dbo.ViwAccFactorDetailPhase1.Avarez, dbo.ViwAccFactorDetailPhase1.Heigh, 
                dbo.ViwAccFactorDetailPhase1.Lenght, dbo.ViwAccFactorDetailPhase1.Width, dbo.ViwAccFactorDetailPhase1.ZowjInUnit, dbo.ViwAccFactorDetailPhase1.Pakaging, dbo.ViwAccFactorDetailPhase1.Oft, 
                dbo.ViwAccFactorDetailPhase1.WarehouseNo, dbo.ViwAccFactorDetailPhase1.SumInFactor, dbo.ViwAccFactorDetailPhase1.OrderTitle AS Expr1, dbo.ViwAccFactorDetailPhase1.OrderID, dbo.ViwAccFactorDetailPhase1.SayerVojoh, 
                dbo.ViwAccFactorDetailPhase1.Nw, dbo.ViwAccFactorDetailPhase1.Ssrv, dbo.ViwAccFactorDetailPhase1.Sscv
FROM      dbo.AccDetail WITH (NOLOCK) RIGHT OUTER JOIN
                dbo.ViwAccFactorDetailPhase1 ON dbo.AccDetail.ID = dbo.ViwAccFactorDetailPhase1.OrderDetailID1 LEFT OUTER JOIN
                dbo.AccControl ON dbo.ViwAccFactorDetailPhase1.OrderControlID = dbo.AccControl.ID LEFT OUTER JOIN
                dbo.AccTotal ON dbo.ViwAccFactorDetailPhase1.OrderTotalID = dbo.AccTotal.ID
GO


