get currency exchange rate using AX Class

static CurrencyExchangeRate getExchRate(CurrencyCode fromCurrency, CurrencyCode toCurrency, TransDate exchangeDate, RefRecId exchangeRateTypeRecId)
{
    ExchangeRateHelper exchangeRateHelper;
    ;

    exchangeRateHelper = ExchangeRateHelper::construct();
    exchangeRateHelper.parmLedgerRecId(Ledger::current());
    exchangeRateHelper.parmFromCurrency(fromCurrency);
    exchangeRateHelper.parmToCurrency(toCurrency);
    exchangeRateHelper.parmExchangeDate(exchangeDate);
    exchangeRateHelper.parmExchangeRateTypeRecId(exchangeRateTypeRecId);

    return ExchangeRateHelper::displayStoredExchangeRate_Static(exchangeRateHelper.getExchangeRate1(),
           ExchangeRateCurrencyPair::getExchangeRateDisplayFactor(fromCurrency, toCurrency, exchangeRateTypeRecId, true));
}

get exchange rate example code

static void TIDF_ExchangeRate(Args _args)
{
    ExchangeRate     exchangeRate;
    ExchangeRateType ExchangeRateType; 
    ExchangeRateCurrencyPair exchangeRateCurrencyPair;
    real             exchRate;
    
    CurrencyCode fromCurrency  = "USD";
    CurrencyCode toCurrency    = "IDR";
    TransDate    transDate     = today();
    
    
    select firstonly exchangeRateCurrencyPair 
    where 
        exchangeRateCurrencyPair.ExchangeRateType == Ledger::find(Ledger::current()).TECFakturPajakAdjustExchangeRateType
    &&  exchangeRateCurrencyPair.FromCurrencyCode == fromCurrency 
    &&  exchangeRateCurrencyPair.ToCurrencyCode   == toCurrency;
    exchRate = exchangeRate::findByDate(exchangeRateCurrencyPair.RecId,transDate).ExchangeRate;
    info(strFmt("%1",exchRate/100));
    
}