-- IF EXISTS(SELECT 1 FROM sys.views WHERE Name = 'quotes_vInventoryToQuoteItem')
-- DROP VIEW [dbo].[quotes_vInventoryToQuoteItem]
-- GO

-- CREATE VIEW [dbo].[quotes_vInventoryToQuoteItem]
-- AS
-- SELECT
-- 	MasterDetails_itemID				= mr.itemID
-- 	,MasterDetails_CEPNumber			= mr.PartsMaster_PartsMasterDetails_PartsMasterCEPNumber
-- 	,MasterDetails_MasterNumber			= mr.PartsMaster_PartsMasterDetails_MasterNumber
-- 	,MasterDetials_PartNumber			= mr.PartsMaster_PartsMasterDetails_PartsMasterPartNumber
-- 	,MasterDetails_Category				= mr.PartsMaster_PartsMasterDetails_PartsCategoryName
-- 	,MasterDetails_Description			= mr.PartsMaster_PartsMasterDetails_PartsMasterDescription
-- 	,MasterDetails_SubCategory			= mr.PartsMaster_PartsMasterDetails_PartsSubCategoryName
-- 	,MasterDetails_MinorCode			= mr.PartsMaster_PartsMasterDetails_PartsMinorCodeName
-- 	,MasterDetails_WeightKG				= mr.PartsMaster_PartsMasterDetails_PartsMasterWeightKG
-- 	,PartDetails_itemID					= i.itemID
-- 	,Management_itemID					= m.itemID
-- 	,Management_isActive				= ISNULL(m.isActive, 1)
-- 	,PartDetails_AverageCost			= ISNULL(i.InventoryItemPartDetails_InventoryItemPartDetails_InventoryItemAverageCost, 0)
-- 	,PartDetails_Brand					= ISNULL(i.InventoryItemPartDetails_InventoryItemPartDetails_InventoryItemsBrand, '')
-- 	,PartDetails_Condition				= i.InventoryItemPartDetails_InventoryItemPartDetails_InventoryItemsCondition
-- 	,PartDetails_Description			= i.InventoryItemPartDetails_InventoryItemPartDetails_InventoryItemsDescription
-- 	,PartDetails_UniqueNumber			= i.InventoryItemPartDetails_InventoryItemPartDetails_InventoryItemsUniqueNumber
-- 	,PartDetails_TotalAvailable			= i.InventoryItemPartDetails_InventoryItemPartDetails_InventoryItemTotalAvailable
-- 	,PartDetails_MasterPartNumber		= i.InventoryItemPartDetails_InventoryItemPartDetails_PartsMasterPartNumber
-- 	,PartDetails_Supplier				= ISNULL(i.InventoryItemPartDetails_InventoryItemPartDetails_Supplier, '')
-- 	,Location_Bin						= m.InventoryManagement_InventoryManagementLocation_InventoryManagementBin
-- 	,Location_BinLocation				= m.InventoryManagement_InventoryManagementLocation_InventoryManagementBinLocation
-- 	,Location_WarehouseLocationName		= m.InventoryManagement_InventoryManagementLocation_WarehouseLocationName
-- FROM publ_PartsMaster mr 
-- 	JOIN publ_InventoryItems i ON mr.itemID = i.ParentSurfaceItemId
-- 	LEFT OUTER JOIN qt_InventoryManagement m ON i.itemID = m.ParentSurfaceItemId 
-- 	and i.InventoryItemPartDetails_InventoryItemPartDetails_InventoryItemsUniqueNumber = m.InventoryManagement_InventoryManagementLocation_InventoryManagementUniqueNumber
-- WHERE mr.isActive = 1 AND i.isActive = 1 AND ISNULL(m.isActive, 1) = 1
-- GO
