/****** Object:  StoredProcedure [dbo].[sp_CAPI1_GetSupplierPricelistParts] ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sp_CAPI1_GetSupplierPricelistParts]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[sp_CAPI1_GetSupplierPricelistParts]
GO
/****** Object:  StoredProcedure [dbo].[sp_CAPI1_GetSupplierCATListParts] ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sp_CAPI1_GetSupplierCATListParts]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[sp_CAPI1_GetSupplierCATListParts]
GO
/****** Object:  StoredProcedure [dbo].[sp_CAPI1_GetPartsAndAlternates] ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sp_CAPI1_GetPartsAndAlternates]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[sp_CAPI1_GetPartsAndAlternates]
GO
/****** Object:  StoredProcedure [dbo].[sp_CAPI1_GetInventoryItems] ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sp_CAPI1_GetInventoryItems]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[sp_CAPI1_GetInventoryItems]
GO
/****** Object:  View [dbo].[vw_CAPI1_Parts] ******/
IF  EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[vw_CAPI1_Parts]'))
DROP VIEW [dbo].[vw_CAPI1_Parts]
GO
/****** Object:  View [dbo].[vw_CAPI1_Parts] ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE VIEW [dbo].[vw_CAPI1_Parts]
AS
SELECT
	RowId					= ISNULl(ROW_NUMBER() OVER(ORDER BY m.itemID), 0) 
	,m.[itemID]
	,IsAlternate			= ISNULL(CAST(0 AS BIT), 0) 
	,CEPNumber				= ISNULL(m.[PartsMaster_PartsMasterDetails_PartsMasterCEPNumber], '')
	,MasterNumber			= LTRIM(RTRIM(UPPER(m.[PartsMaster_PartsMasterDetails_MasterNumber])))
	,PartNumber				= LTRIM(RTRIM(UPPER(m.[PartsMaster_PartsMasterDetails_PartsMasterPartNumber])))
	,AlternateNumber		= '' 
	,[Description]			= ISNULL(m.[PartsMaster_PartsMasterDetails_PartsMasterDescription], '')
	,AdditionalDescription	= ISNULL(m.[PartsMaster_PartsMasterDetails_PartsMasterAdditionalDescription], '') 
	,DimensionalDescription = ISNULL(m.[PartsMaster_PartsMasterDetails_PartsMasterDimensionalDescription], '') 
	,WeightKG				= ISNULL(m.[PartsMaster_PartsMasterDetails_PartsMasterWeightKG], 0) 
	,CategoryName			= ISNULL(m.[PartsMaster_PartsMasterDetails_PartsCategoryName], '') 
	,SubCategoryName		= ISNULL(m.[PartsMaster_PartsMasterDetails_PartsSubCategoryName], '') 
	,MinorCodeName			= ISNULL(m.[PartsMaster_PartsMasterDetails_PartsMinorCodeName], '') 
	,TotalAvailable			= ISNULL(m.[InventoryManagement_InventoryManagement_InventoryTotalAvailable], 0) 
	,IsVetted				= ISNULL(CAST(m.[PartsMaster_PartsMasterDetails_PartsMasterItemVetted] AS BIT), 0) 
	,VettedBy				= ISNULL(m.[PartsMaster_PartsMasterDetails_PartsMasterItemVettedBy], '') 
	,UniqueNumber =			convert(varchar(16),m.[itemID])+'-'+m.[PartsMaster_PartsMasterDetails_PartsMasterCEPNumber]
FROM [publ_PartsMaster] m
WHERE m.PartsMaster_PartsMasterDetails_MasterNumber != ''
	AND m.PartsMaster_PartsMasterDetails_PartsMasterPartNumber != ''
	AND m.isActive = 1
UNION ALL
SELECT
	RowId					= ISNULl(ROW_NUMBER() OVER(ORDER BY m.itemID), 0) 
	,m.[itemID]
	,IsAlternate			= ISNULL(CAST(1 AS BIT), 1) 
    ,CEPNumber				= ISNULL(m.[PartsMaster_PartsMasterDetails_PartsMasterCEPNumber], '')
    ,MasterNumber			= LTRIM(RTRIM(UPPER(m.[PartsMaster_PartsMasterDetails_PartsMasterPartNumber])))
	,PartNumber				= LTRIM(RTRIM(UPPER(m.[PartsMaster_PartsMasterDetails_PartsMasterPartNumber])))
    ,AlternateNumber		= LTRIM(RTRIM(UPPER(a.[PartsAlternates_PartsAlternates_AlternatePartNumber])))
	,[Description]			= ISNULL(m.[PartsMaster_PartsMasterDetails_PartsMasterDescription], '')
	,AdditionalDescription	= ISNULL(m.[PartsMaster_PartsMasterDetails_PartsMasterAdditionalDescription], '') 
	,DimensionalDescription = ISNULL(m.[PartsMaster_PartsMasterDetails_PartsMasterDimensionalDescription], '') 
	,WeightKG				= ISNULL(m.[PartsMaster_PartsMasterDetails_PartsMasterWeightKG], 0) 
	,CategoryName			= ISNULL(m.[PartsMaster_PartsMasterDetails_PartsCategoryName], '') 
	,SubCategoryName		= ISNULL(m.[PartsMaster_PartsMasterDetails_PartsSubCategoryName], '') 
	,MinorCodeName			= ISNULL(m.[PartsMaster_PartsMasterDetails_PartsMinorCodeName], '') 
	,TotalAvailable			= ISNULL(m.[InventoryManagement_InventoryManagement_InventoryTotalAvailable], 0) 
	,IsVetted				= ISNULL(CAST(m.[PartsMaster_PartsMasterDetails_PartsMasterItemVetted] AS BIT), 0) 
	,VettedBy				= ISNULL(m.[PartsMaster_PartsMasterDetails_PartsMasterItemVettedBy], '') 
	,UniqueNumber			= convert(varchar(16),m.[itemID])+'-'+m.[PartsMaster_PartsMasterDetails_PartsMasterCEPNumber]+'-'+a.[PartsAlternates_PartsAlternates_AlternatePartNumber]
FROM [publ_PartsAlternates] a
	JOIN [publ_PartsMaster] m on a.PartsAlternates_PartsAlternates_PartsMasterPartNumber = m.PartsMaster_PartsMasterDetails_PartsMasterPartNumber
	WHERE m.PartsMaster_PartsMasterDetails_MasterNumber != ''
	AND a.PartsAlternates_PartsAlternates_AlternatePartNumber != ''
	AND a.isActive = 1
	AND m.isActive = 1
	AND m.PartsMaster_PartsMasterDetails_PartsMasterPartNumber != a.PartsAlternates_PartsAlternates_AlternatePartNumber
	AND a.ParentSurfaceItemId > 0
GO
/****** Object:  StoredProcedure [dbo].[sp_CAPI1_GetInventoryItems] ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[sp_CAPI1_GetInventoryItems] 
	-- Add the parameters for the stored procedure here
	@partNumbers nvarchar(max)
	,@delimeter nvarchar(64) = '|'
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

	DECLARE @partNums TABLE (
		partNumber varchar(64)
	)

	INSERT INTO @partNums (partNumber)
	SELECT LTRIM(RTRIM(UPPER(splitdata))) splitdata FROM SplitString(@partNumbers, @delimeter)
		-- exclude empty strings
		WHERE splitdata != ''

    -- Insert statements for procedure here
	SELECT
		MasterId				= mr.itemID
		,InventoryId			= i.itemID
		,ManagementId			= ISNULL(m.itemID, 0)
		,AdditionalDescription	= ISNULL(mr.PartsMaster_PartsMasterDetails_PartsMasterAdditionalDescription, '')
		,Available				= ISNULL(CONVERT(int, m.InventoryManagement_InventoryManagementStockDetails_InventoryManagementAvailable), 0)
		,AverageCost			= ISNULL(i.InventoryItemPartDetails_InventoryItemPartDetails_InventoryItemAverageCost, 0)
		,Bin					= ISNULL(m.InventoryManagement_InventoryManagementLocation_InventoryManagementBin, '')
		,BinLocation			= ISNULL(m.InventoryManagement_InventoryManagementLocation_InventoryManagementBinLocation, '')
		,Brand					= ISNULL(i.InventoryItemPartDetails_InventoryItemPartDetails_InventoryItemsBrand, '')
		,Category				= ISNULL(mr.PartsMaster_PartsMasterDetails_PartsCategoryName, '')
		,CEPNumber				= ISNULL(mr.PartsMaster_PartsMasterDetails_PartsMasterCEPNumber, '')
		,Condition				= ISNULL(i.InventoryItemPartDetails_InventoryItemPartDetails_InventoryItemsCondition, '')
		,[Description]			= ISNULL(mr.PartsMaster_PartsMasterDetails_PartsMasterDescription, '')
		,MasterNumber			= ISNULL(LTRIM(RTRIM(UPPER(mr.PartsMaster_PartsMasterDetails_MasterNumber))), '')
		,MinorCode				= ISNULL(mr.PartsMaster_PartsMasterDetails_PartsMinorCodeName, '')
		,PartNumber				= ISNULL(LTRIM(RTRIM(UPPER(mr.PartsMaster_PartsMasterDetails_PartsMasterPartNumber))), '')
		,SubCategory			= ISNULL(mr.PartsMaster_PartsMasterDetails_PartsSubCategoryName, '')
		,UniqueNumber			= ISNULL(UPPER(i.InventoryItemPartDetails_InventoryItemPartDetails_InventoryItemsUniqueNumber), '')
		,WarehouseLocation		= ISNULL(m.InventoryManagement_InventoryManagementLocation_WarehouseLocationName, '')
		,WeightKG				= ISNULL(mr.PartsMaster_PartsMasterDetails_PartsMasterWeightKG, 0)
	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
		AND i.InventoryItemPartDetails_InventoryItemPartDetails_InventoryItemTotalAvailable > 0
		AND (
			ISNULL(LTRIM(RTRIM(UPPER(mr.PartsMaster_PartsMasterDetails_MasterNumber))), '') IN (SELECT partNumber FROM @partNums)
			OR ISNULL(LTRIM(RTRIM(UPPER(mr.PartsMaster_PartsMasterDetails_PartsMasterPartNumber))), '') IN (SELECT partNumber FROM @partNums)
			)
END
GO
/****** Object:  StoredProcedure [dbo].[sp_CAPI1_GetPartsAndAlternates] ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[sp_CAPI1_GetPartsAndAlternates] (
	@partNumbers nvarchar(max)
	,@delimeter nvarchar(64)
)
AS
BEGIN
	-- will hold the individual part numbers as rows
	DECLARE @partNums TABLE (
		partNumber varchar(64)
	)

	INSERT INTO @partNums (partNumber)
	SELECT LTRIM(RTRIM(UPPER(splitdata))) splitdata FROM SplitString(@partNumbers, @delimeter)
		-- exclude empty strings
		WHERE splitdata != ''

	SELECT * 
		FROM vw_CAPI1_Parts t
		WHERE t.MasterNumber IN (SELECT partNumber FROM @partNums)
	UNION ALL
	(
		SELECT m.*
		  FROM vw_CAPI1_Parts a
			JOIN vw_CAPI1_Parts m 
				ON a.PartNumber = m.PartNumber
			WHERE a.AlternateNumber IN (SELECT partNumber FROM @partNums)
	)
END
GO
/****** Object:  StoredProcedure [dbo].[sp_CAPI1_GetSupplierCATListParts] ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[sp_CAPI1_GetSupplierCATListParts] 
	-- Add the parameters for the stored procedure here
	@partNumbers nvarchar(max)
	,@delimeter nvarchar(64)
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

	-- will hold the individual part numbers as rows
	DECLARE @partNums TABLE (
		partNumber varchar(64)
	)

	INSERT INTO @partNums (partNumber)
	SELECT LTRIM(RTRIM(UPPER(splitdata))) splitdata FROM SplitString(@partNumbers, @delimeter)
		-- exclude empty strings
		WHERE splitdata != ''

    -- Insert statements for procedure here
	SELECT [itemID]
      ,[isActive]
      ,[surfaceId]
      ,[ParentSurfaceItemId]
      ,[SupplierPricelistParts_SupplierPricelistParts_SupplierPricelistPartsLastUpdatedOn]
      ,[SupplierPricelistParts_SupplierPricelistParts_SupplierPricelistPartsLastUpdatedBy]
      ,[SupplierPricelistParts_SupplierPricelistParts_SupplierPricelistPartsPricelistStatus]
      ,[SupplierPricelistParts_SupplierPricelistParts_SupplierPricelistPartsExpiryDate]
      ,[SupplierPricelistParts_SupplierPricelistParts_SupplierPricelistPartsLeadTime]
      ,[SupplierPricelistParts_SupplierPricelistParts_SupplierPricelistPartsPartNumber] = LTRIM(RTRIM(UPPER([SupplierPricelistParts_SupplierPricelistParts_SupplierPricelistPartsPartNumber])))
      ,[SupplierPricelistParts_SupplierPricelistParts_SupplierPricelistPartsSupplierName]
      ,[SupplierPricelistParts_SupplierPricelistParts_SupplierPricelistPartsAlternateNumbers]
      ,[SupplierPricelistParts_SupplierPricelistParts_SupplierPricelistPartsDescription]
      ,[SupplierPricelistParts_SupplierPricelistParts_SupplierPricelistPartsAdditionalDescription]
      ,[SupplierPricelistParts_SupplierPricelistParts_SupplierPricelistPartsBrand]
      ,[SupplierPricelistParts_SupplierPricelistParts_SupplierPricelistPartsCondition]
      ,[SupplierPricelistParts_SupplierPricelistParts_WeightKG]
      ,[SupplierPricelistParts_SupplierPricelistParts_WeightLBS]
      ,[SupplierPricelistParts_SupplierPricelistParts_SupplierPricelistPartsCurrency]
      ,[SupplierPricelistParts_SupplierPricelistParts_SupplierPricelistPartsSalesPrice]
      ,[SupplierPricelistParts_SupplierPricelistParts_SupplierPricelistPartsAvailability]
      ,[SupplierPricelistParts_SupplierPricelistParts_SupplierPricelistPartsNote]
      ,[recId]
  FROM [publ_SupplierPricelistParts]
  Where 
	isActive = 1
	AND 'Current' = SupplierPricelistParts_SupplierPricelistParts_SupplierPricelistPartsPricelistStatus
	AND 'CAT' = SupplierPricelistParts_SupplierPricelistParts_SupplierPricelistPartsSupplierName
	AND LTRIM(RTRIM(UPPER([SupplierPricelistParts_SupplierPricelistParts_SupplierPricelistPartsPartNumber])))
		IN (SELECT partNumber FROM @partNums)
END
GO
/****** Object:  StoredProcedure [dbo].[sp_CAPI1_GetSupplierPricelistParts] ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[sp_CAPI1_GetSupplierPricelistParts] 
	-- Add the parameters for the stored procedure here
	@partNumbers nvarchar(max)
	,@delimeter nvarchar(64) = '|'
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

	DECLARE @partNums TABLE (
		partNumber varchar(64)
	)

	INSERT INTO @partNums (partNumber)
	SELECT LTRIM(RTRIM(UPPER(splitdata))) splitdata FROM SplitString(@partNumbers, @delimeter)
		-- exclude empty strings
		WHERE splitdata != ''

    -- Insert statements for procedure here
		SELECT 
            PartNumber, 
			AlternateNumber,
			SupplierName, 
            Brand, 
            Condition, 
            Currency, 
            LeadTime, 
            [Availability], 
            Note, 
			SalesPrice,
            WeightKG,
			[Description]
            FROM 
			( 
                SELECT 
				SupplierName	= ISNULL(p.SupplierPricelistParts_SupplierPricelistParts_SupplierPricelistPartsSupplierName, ''),  
				PartNumber		= LTRIM(RTRIM(UPPER(ISNULL(p.SupplierPricelistParts_SupplierPricelistParts_SupplierPricelistPartsPartNumber, '')))),
				AlternateNumber = LTRIM(RTRIM(UPPER(ISNULL(m.PartsAlternates_PartsAlternates_PartsMasterPartNumber, p.SupplierPricelistParts_SupplierPricelistParts_SupplierPricelistPartsPartNumber)))), 
				Brand			= ISNULL(p.SupplierPricelistParts_SupplierPricelistParts_SupplierPricelistPartsBrand, ''), 
				Condition		= ISNULL(p.SupplierPricelistParts_SupplierPricelistParts_SupplierPricelistPartsCondition, ''), 
				Currency		= ISNULL(p.SupplierPricelistParts_SupplierPricelistParts_SupplierPricelistPartsCurrency, 'ZAR'), 
				LeadTime		= ISNULL(p.SupplierPricelistParts_SupplierPricelistParts_SupplierPricelistPartsLeadTime, ''), 
				--AlternateNumbers = ISNULL(p.SupplierPricelistParts_SupplierPricelistParts_SupplierPricelistPartsAlternateNumbers, ''), 
				[Availability]	= ISNULL(p.SupplierPricelistParts_SupplierPricelistParts_SupplierPricelistPartsAvailability, 0), 
				Note			= ISNULL(p.SupplierPricelistParts_SupplierPricelistParts_SupplierPricelistPartsNote, ''), 
				SalesPrice		= ISNULL(p.SupplierPricelistParts_SupplierPricelistParts_SupplierPricelistPartsSalesPrice, 0),  
				WeightKG		= ISNULL(p.SupplierPricelistParts_SupplierPricelistParts_WeightKG, 0),
				[Description]	= ISNULL(p.SupplierPricelistParts_SupplierPricelistParts_SupplierPricelistPartsDescription, ''),
				PriceRank		= ROW_NUMBER() OVER (PARTITION BY  
					p.SupplierPricelistParts_SupplierPricelistParts_SupplierPricelistPartsSupplierName,   
					ISNULL(m.PartsAlternates_PartsAlternates_PartsMasterPartNumber, p.SupplierPricelistParts_SupplierPricelistParts_SupplierPricelistPartsPartNumber),  
					p.SupplierPricelistParts_SupplierPricelistParts_SupplierPricelistPartsBrand,  
					p.SupplierPricelistParts_SupplierPricelistParts_SupplierPricelistPartsCondition,  
					p.SupplierPricelistParts_SupplierPricelistParts_SupplierPricelistPartsCurrency,  
					p.SupplierPricelistParts_SupplierPricelistParts_SupplierPricelistPartsLeadTime,  
					p.SupplierPricelistParts_SupplierPricelistParts_SupplierPricelistPartsAlternateNumbers,  
					p.SupplierPricelistParts_SupplierPricelistParts_SupplierPricelistPartsNote,  
					p.SupplierPricelistParts_SupplierPricelistParts_SupplierPricelistPartsAvailability   
					ORDER BY p.SupplierPricelistParts_SupplierPricelistParts_SupplierPricelistPartsSalesPrice DESC)  
                FROM publ_SupplierPricelistParts p   
					LEFT OUTER JOIN publ_PartsAlternates m ON 
						m.PartsAlternates_PartsAlternates_AlternatePartNumber = p.SupplierPricelistParts_SupplierPricelistParts_SupplierPricelistPartsPartNumber   
                WHERE p.isActive = 1 
					AND p.SupplierPricelistParts_SupplierPricelistParts_SupplierPricelistPartsPricelistStatus = 'Current'  
					AND p.SupplierPricelistParts_SupplierPricelistParts_SupplierPricelistPartsSupplierName IN ('CAT', 'SURPLUS WAREHOUSE')  
					AND p.SupplierPricelistParts_SupplierPricelistParts_SupplierPricelistPartsPartNumber IN (SELECT partNumber FROM @partNums)
        ) t   
        WHERE t.PriceRank = 1  
        UNION  
        SELECT 
			PartNumber		= LTRIM(RTRIM(UPPER(ISNULL(SupplierPricelistParts_SupplierPricelistParts_SupplierPricelistPartsPartNumber, '')))), 
			AlternateNumber = LTRIM(RTRIM(UPPER(ISNULL(p.SupplierPricelistParts_SupplierPricelistParts_SupplierPricelistPartsPartNumber, '')))),
			SupplierName	= ISNULL(SupplierPricelistParts_SupplierPricelistParts_SupplierPricelistPartsSupplierName, ''), 
			Brand			= ISNULL(SupplierPricelistParts_SupplierPricelistParts_SupplierPricelistPartsBrand, ''), 
			Condition		= ISNULL(SupplierPricelistParts_SupplierPricelistParts_SupplierPricelistPartsCondition, ''), 
			Currency		= ISNULL(SupplierPricelistParts_SupplierPricelistParts_SupplierPricelistPartsCurrency, 'ZAR'), 
			LeadTime		= ISNULL(SupplierPricelistParts_SupplierPricelistParts_SupplierPricelistPartsLeadTime, ''), 
			[Availability]	= ISNULL(SupplierPricelistParts_SupplierPricelistParts_SupplierPricelistPartsAvailability, 0), 
			Note			= ISNULL(SupplierPricelistParts_SupplierPricelistParts_SupplierPricelistPartsNote, ''), 
			SalesPrice		= ISNULL(SupplierPricelistParts_SupplierPricelistParts_SupplierPricelistPartsSalesPrice, 0),
			WeightKG		= ISNULL(p.SupplierPricelistParts_SupplierPricelistParts_WeightKG, 0),
			[Description]	= ISNULL(p.SupplierPricelistParts_SupplierPricelistParts_SupplierPricelistPartsDescription, '')
        FROM publ_SupplierPricelistParts p 
        WHERE p.isActive = 1
			AND p.SupplierPricelistParts_SupplierPricelistParts_SupplierPricelistPartsPartNumber in (SELECT partNumber FROM @partNums) 
			AND p.SupplierPricelistParts_SupplierPricelistParts_SupplierPricelistPartsPricelistStatus = 'Current' 
			AND p.SupplierPricelistParts_SupplierPricelistParts_SupplierPricelistPartsSupplierName NOT IN ('CAT', 'SURPLUS WAREHOUSE') 
END
GO
