Issue:
When working in an AP Vendor we are receiving errors that the application cannot find function or aggregate dbo.fnInvoice_Credit_Amount.

Resolution:
The function is used by the application and cannot be found as expected. There may have been a problem when the database was updated, and the function was not created correctly, or the function was deleted from the database by mistake.
The script below will recreate the function if it no longer exists.
/****** Object: UserDefinedFunction [dbo].[fnInvoice_Credit_Amount] Script Date: 11/20/2024 3:51:34 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE FUNCTION [dbo].[fnInvoice_Credit_Amount]
(@APInvoice_Id int)
RETURNS money
AS
BEGIN
DECLARE @Amount money
SELECT @Amount = SUM(cd.Amount)
FROM AP_Credit_Detail cd
WHERE cd.APInvoice_Id = @apinvoice_id
RETURN @Amount
END
GO