Exchange rate operations:
Convert to accounting currency:
CurrencyExchangeHelper::amountCur2MST(amount, currencyCodeFrom[, fixedExchRate]);Convert to a different currency:
CurrencyExchangeHelper::curAmount2CurAmount(amount, currencyCodeFrom, CurrencyCodeTo);Get accounting currency:
CurrencyCode accountingCurrency = Ledger::accountingCurrency();
CurrencyCode accountingCurrency = Ledger::accountingCurrencyByLedger(_ledgerRecId);Get reporting currency:
CurrencyCode accountingCurrency = Ledger::reportingCurrency();
CurrencyCode accountingCurrency = Ledger::reportingCurrencyByLedger(_ledgerRecId);Convert currency with a class instance:
CurrencyExchangeHelper currencyExchangeHelper = CurrencyExchangeHelper::newExchangeDate(
Ledger::current(),
DateTimeUtil::getSystemDate(DateTimeUtil::getUserPreferredTimeZone())
);
currencyExchangeHelper.calculateTransactionToAccounting(currencyCodeFrom, amountCur, true);
// currencyExchangeHelper.calculateCurrencyToCurrency()
currencyExchangeHelper.parmExchangeRate1();Get the exchange rate:
//accounting currency
ExchangeRateCalculation exchangeRateCalculation = ExchangeRateCalculation::newExchangeDate(Ledger::defaultExchangeRateType(),
purchTable.CurrencyCode,
Ledger::accountingCurrency(),
DateTimeUtil::getSystemDate(DateTimeUtil::getUserPreferredTimeZone()));
purchTable.FixedExchRate = exchangeRateCalculation.getExchangeRate1();
// reporting currency
ExchangeRateCalculation exchangeRateCalculation = ExchangeRateCalculation::newExchangeDate(Ledger::reportingCurrencyExchangeRateType(),
currencyCodeFrom,
currencyCodeTo,
DateTimeUtil::getSystemDate(DateTimeUtil::getUserPreferredTimeZone()));
exchangeRateCalculation.getExchangeRate1();Support The Author
If you found value in what I share, I've set up a Buy Me a Coffee page as a way to show your support.
No comments. Be the first one to comment on this post.
DaxOnline.org is free platform that allows you to quickly store and reuse snippets, notes, articles related to Dynamics 365 FO.
Authors are allowed to set their own "buy me a coffee" link.
Join us.