Monday 16 September 2019

How to get Exchange rate in D365 F&O x++ ?



public display Amount TIDF_ExchangeRate()
{
    ExchangeRate     exchangeRate;
    ExchangeRateType ExchangeRateType;
    ExchangeRateCurrencyPair exchangeRateCurrencyPair;
    real             exchRate;

    CurrencyCode fromCurrency  = this.CurrencyCode;
    CurrencyCode toCurrency    = Ledger::find(Ledger::current()).AccountingCurrency ; //"AED";
    TransDate    transDate     = this.TransDate;


    select firstonly exchangeRateCurrencyPair
    where
        exchangeRateCurrencyPair.ExchangeRateType == Ledger::find(Ledger::current()).DefaultExchangeRateType
    &&  exchangeRateCurrencyPair.FromCurrencyCode == fromCurrency
    &&  exchangeRateCurrencyPair.ToCurrencyCode   == toCurrency;

   // if ( date2str(this.TransDate ,1,1,1) == 5/9/2018);
    exchRate = exchangeRate::findByDate(exchangeRateCurrencyPair.RecId,transDate).ExchangeRate;
    //info(strFmt("%1",exchRate/100));

    return exchRate/100;

}








No comments:

Post a Comment

Adding a newline into a string in C# and X++

Below is the sample code we can use for  adding a newline after every occurrence of "@" symbol in the string in C#   using System...