/****** Object:  View [dbo].[ViwAccFactor]    Script Date: 1/28/2024 09:45:36 ق.ظ ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

ALTER VIEW [dbo].[ViwAccFactor]
AS
SELECT   Phas1.Number, Phas1.UserNumber, Phas1.Date, dbo.FARSI_DATE2(Phas1.Date) AS DatePer, Phas1.ID AS FactorNo, Phas1.PersonTotalID, Phas1.PersonControlID, Phas1.PersonDetailID1, Phas1.PersonDetailID2, Phas1.Description, 
                Phas1.UpdateDate, Phas1.Updater, COALESCE (dbo.AccDetail.Title, Phas1.PersonTitle) AS PersonTitle, Detail.ID, Detail.FactorID, Detail.Request, Detail.NetPrice, Detail.TotalPrice, Detail.RequestUnit, Detail.UnitName, Detail.OrderTitle, 
                Detail.OrderTotalID, Detail.OrderControlID, Detail.OrderDetailID1, Detail.OrderDetailID2, Detail.DocItemID, Detail.DocHeaderID, Detail.Status, Detail.Selected, COALESCE (Detail.Unit2, 0) AS Unit2, COALESCE (Detail.Value2, 0) AS Value2, 
                COALESCE (Detail.Unit2Name, N'') AS Unit2Name, Detail.Maliat, Detail.Avarez, Detail.Discont, Phas1.Paid, Phas1.IsPermanent, Phas1.PayTime, Phas1.PayType, Phas1.Type, Phas1.SeriallID, Phas1.PersonAddress, Phas1.PersonFinancialCode, 
                Phas1.PersonTel, Phas1.PersonFax, Phas1.PersonEmail, Phas1.PersonWeb, Phas1.Discont AS FactorDiscont, Phas1.DiscontIsPercent, Phas1.DiscontTotalID, Phas1.DiscontControlID, Phas1.DiscontDetailID1, Phas1.DiscontDetailID2, 
                Phas1.WarehouseID, Phas1.WareOutID, Phas1.FromWarehouse, Phas1.Avarez AS FactorAvarez, Phas1.AvarezIsPercent, Phas1.AvarezTotalID, Phas1.AvarezControlID, Phas1.AvarezDetailID1, Phas1.AvarezDetailID2, Phas1.Haml, 
                Phas1.HamlIsPercent, Phas1.HamlTotalID, Phas1.HamlControlID, Phas1.HamlDetailID1, Phas1.HamlDetailID2, Phas1.VizitorTotalID, Phas1.VizitorControlID, Phas1.VizitorDetailID1, Phas1.VizitorDetailID2, Phas1.SellType, Detail.OtherTitle, 
                Detail.Heigh, Detail.Lenght, Detail.Width, Detail.ZowjInUnit, Detail.Pakaging, Detail.Oft, Detail.WarehouseNo, Detail.SumInFactor, Phas1.PersonCodePosti, Phas1.PersonSabt, Phas1.PersonShenase, Phas1.CostCenter, Phas1.Project, 
                Phas1.OrderID, Phas1.IsFalsi, Phas1.Zir5Darsad, Phas1.HaghAmalKari, Phas1.Type1Code, Phas1.CityCode, Phas1.KalaTypeID, Phas1.PrePayment, Phas1.UID, Phas1.TaxUID, Phas1.TaxType, Phas1.TaxIns, Phas1.Taxid, Phas1.Irtaxid, 
                Phas1.IrID, Phas1.Cdcn, Phas1.Cdcd, Phas1.Cut, Phas1.Exr, Detail.OrderID AS Expr1, Detail.SayerVojoh, Detail.Nw, Detail.Ssrv, Detail.Sscv, Phas1.Scc
FROM      dbo.ViwAccFactorPhas1 AS Phas1 WITH (NOLOCK) LEFT OUTER JOIN
                dbo.ViwAccFactorDetail AS Detail WITH (NOLOCK) ON Phas1.ID = Detail.FactorID LEFT OUTER JOIN
                dbo.AccDetail ON Phas1.PersonDetailID2 = dbo.AccDetail.ID
GO


