/****** Object:  View [dbo].[ViwAccFactorPhas1]    Script Date: 05/02/1402 03:00:36 ب.ظ ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

ALTER VIEW [dbo].[ViwAccFactorPhas1]
AS
SELECT   dbo.AccFactor.ID, dbo.AccFactor.Type, dbo.AccFactor.Number, dbo.AccFactor.UserNumber, dbo.AccFactor.Date, dbo.AccFactor.SeriallID, dbo.AccFactor.PersonTotalID, dbo.AccFactor.PersonControlID, dbo.AccFactor.PersonDetailID1, 
                dbo.AccFactor.PersonDetailID2, dbo.AccFactor.PersonAddress, dbo.AccFactor.PersonFinancialCode, dbo.AccFactor.PersonTel, dbo.AccFactor.PersonFax, dbo.AccFactor.PersonEmail, dbo.AccFactor.PersonWeb, dbo.AccFactor.Description, 
                dbo.AccFactor.Discont, dbo.AccFactor.DiscontIsPercent, dbo.AccFactor.PayType, dbo.AccFactor.UpdateDate, dbo.AccFactor.Updater, dbo.AccFactor.DiscontTotalID, dbo.AccFactor.DiscontControlID, dbo.AccFactor.DiscontDetailID1, 
                dbo.AccFactor.DiscontDetailID2, dbo.AccFactor.WarehouseID, dbo.AccFactor.WareOutID, dbo.AccFactor.FromWarehouse, dbo.AccFactor.Avarez, dbo.AccFactor.AvarezIsPercent, dbo.AccFactor.AvarezTotalID, dbo.AccFactor.AvarezControlID, 
                dbo.AccFactor.AvarezDetailID1, dbo.AccFactor.AvarezDetailID2, dbo.AccFactor.Haml, dbo.AccFactor.HamlIsPercent, dbo.AccFactor.HamlTotalID, dbo.AccFactor.HamlControlID, dbo.AccFactor.HamlDetailID1, dbo.AccFactor.HamlDetailID2, 
                dbo.AccFactor.PayTime, COALESCE (dbo.AccDetail.Title, dbo.AccControl.Title, dbo.AccTotal.Title) AS PersonTitle, dbo.AccFactor.IsPermanent, dbo.AccFactor.Paid, dbo.AccFactor.VizitorTotalID, dbo.AccFactor.VizitorControlID, 
                dbo.AccFactor.VizitorDetailID1, dbo.AccFactor.VizitorDetailID2, dbo.AccFactor.SellType, dbo.AccFactor.PersonCodePosti, dbo.AccFactor.PersonSabt, dbo.AccFactor.PersonShenase, dbo.AccFactor.CostCenter, dbo.AccFactor.Project, 
                dbo.AccFactor.OrderID, dbo.AccFactor.IsFalsi, dbo.AccFactor.Zir5Darsad, dbo.AccFactor.HaghAmalKari, dbo.AccFactor.Type1Code, dbo.AccFactor.CityCode, dbo.AccFactor.KalaTypeID, dbo.AccFactor.PrePayment, dbo.AccFactor.UID, 
                dbo.AccFactor.TaxUID, dbo.AccFactor.TaxType
FROM      dbo.AccFactor WITH (NOLOCK) LEFT OUTER JOIN
                dbo.AccTotal ON dbo.AccFactor.PersonTotalID = dbo.AccTotal.ID LEFT OUTER JOIN
                dbo.AccControl ON dbo.AccFactor.PersonControlID = dbo.AccControl.ID LEFT OUTER JOIN
                dbo.AccDetail ON dbo.AccFactor.PersonDetailID1 = dbo.AccDetail.ID
GO


