﻿-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date, ,>
-- Description:	<Description, ,>
-- =============================================
CREATE FUNCTION [dbo].[fds__fn_InvoiceIDs_mfr]
(
	@invoiceid varchar(255),
	@other varchar(1000)
)
RETURNS varchar(1000)
AS
BEGIN
	DECLARE @RET varchar(1000) = REPLACE(LTRIM(ISNULL(@invoiceid,'')),'Preview','');
	
	IF @RET <> ''
		SET @RET = TRIM(REPLACE(@RET, '  ', ' '));

	IF @RET <> ''
		SET @RET = REPLACE(@RET, ' ',' (mfr)' + CHAR(10)) + ' (mfr)';

	IF @RET <> '' AND ISNULL(@other, '') <> ''
		SET @RET = @RET + CHAR(10);

	SET @RET = @RET + ISNULL(@other, '');
		
	
	RETURN @RET;

END