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;
}
Great walkthrough on retrieving exchange rates in D365 Finance & Operations using X++. The use of ExchangeRateCurrencyPair and exchangeRate::findByDate() makes it clear how to dynamically fetch conversion rates based on transaction date. Very handy when working with multi-currency ledgers! For frontend developers, exploring tools like html2canvas alternatives can also help when rendering or exporting data visuals from web applications.
ReplyDelete