I want to calculate the amount in USD (the origin amount / exchange rate if it is LCY) the customer ledger entry and add that to query. I tried to create a procedure in the query to calculate it but how i can add this in the dataitem. This is my code
query 50115 Payments
{
QueryType = API;
APIPublisher = 'Muaaz';
APIGroup = 'Sales';
APIVersion = 'v2.0';
EntityName = 'Payments';
EntitySetName = 'Payments';
elements
{
dataitem(Cust__Ledger_Entry; "Cust. Ledger Entry")
{
column(Posting_Date; "Posting Date")
{
Caption = 'Posting_Date', Locked = true;
}
column(Customer_No_; "Customer No.")
{
Caption = 'Customer_No', Locked = true;
}
column(Document_Type; "Document Type")
{
Caption = 'Document Type', Locked = true;
}
column(Amount__LCY_; "Amount (LCY)")
{
Caption = 'Payment Amount', Locked = true;
}
d
}
}
local procedure GetAmountUSD(CustLedEntry: Record "Cust. Ledger Entry"): Decimal
var
CurrExchangeRate: Record "Currency Exchange Rate";
begin
if CustLedEntry."Currency Code" = '' then begin
CurrExchangeRate.SetRange("Currency Code", 'USD');
CurrExchangeRate.SetRange("Starting Date", 0D, CustLedEntry."Posting Date");
if CurrExchangeRate.FindLast() then
AmountUSD := CustLedEntry."Original Amount" / CurrExchangeRate."Relational Exch. Rate Amount"
else
AmountUSD := CustLedEntry."Original Amount";
end;
end;
var
AmountUSD: Decimal;
}
I can not figure out how to add this variable to the dataitem. Is there anyway i can do this?