PROCEDURE CalcCustLedgActualCostLCY@128(CustLedgEntry@1000 : Record 21) : Decimal;
VAR
ValueEntry@1001 : Record 5802;
BEGIN
WITH CustLedgEntry DO BEGIN
IF NOT ("Document Type" IN ["Document Type"::Invoice,"Document Type"::"Credit Memo"]) THEN
FIELDERROR("Document Type");
ValueEntry.SETCURRENTKEY("Document No.");
ValueEntry.SETRANGE("Document No.","Document No.");
IF "Document Type" = "Document Type"::Invoice THEN
ValueEntry.SETFILTER(
"Document Type",
'%1|%2',
ValueEntry."Document Type"::"Sales Invoice",ValueEntry."Document Type"::"Service Invoice")
ELSE
ValueEntry.SETFILTER(
"Document Type",
'%1|%2',
ValueEntry."Document Type"::"Sales Credit Memo",ValueEntry."Document Type"::"Service Credit Memo");
ValueEntry.SETFILTER("Entry Type",'<> %1',ValueEntry."Entry Type"::Revaluation);
EXIT(SumValueEntriesCostAmt(ValueEntry));
END;
END;