USE [envisage]
GO
/****** Object:  View [dbo].[VW_Expenditure2Calculation]    Script Date: 06/19/2014 22:50:11 ******/
IF  EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[VW_Expenditure2Calculation]'))
DROP VIEW [dbo].[VW_Expenditure2Calculation]

/****** Object:  View [dbo].[VW_Expenditure2Calculation]    Script Date: 06/19/2014 22:50:54 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE VIEW [dbo].[VW_Expenditure2Calculation]
AS
	SELECT Expenditure2Expenditure.Id,
		Expenditure_Category.Id AS ExpenditureCategoryID,
		Expenditure_Category.GLId,
		Expenditure_Category.UOMId,
		Expenditure_Category.Type,
		Expenditure_Category.UseType,
		Expenditure_Category.CGEFX,
		Expenditure_Category.SortOrder,
		Expenditure_Category.SystemAttributeOne,
		Expenditure_Category.SystemAttributeTwo,
		Expenditure.Name As ExpenditureName,
		Expenditure2Expenditure.FactorType,
		Expenditure2Expenditure.FactorInt,
		Expenditure2Expenditure.ProcessOrder,
		Expenditure2Expenditure.ParentId,
		Expenditure_Category.CreditId,
		Expenditure_Category.WksSubjectToFee
 	  FROM Expenditure2Expenditure 
		LEFT OUTER JOIN Expenditure
		INNER JOIN Expenditure_Category ON Expenditure.Id = Expenditure_Category.ExpenditureId 
			ON Expenditure2Expenditure.ChildId = Expenditure_Category.Id
