CurrencyExchangeHelper class in Dynamics AX 2012 [X++]
Friends,
In Microsoft Dynamics AX 2012, the currency and exchange rate framework has been enhanced to share information across multiple legal entities.
There is a new class by name CurrencyExchangeHelper that has been introduced in AX 2012 to support this.
This class will help you to do some calculations between currencies. Some important methods to use:
calculateTransactionToAccounting
Example : This method will convert the transaction currency in to accounting currency defined in ledger Table.
static void SR_CEH_Example1(Args _args)
{
CurrencyExchangeHelper currencyExchangeHelper;
CurrencyCode transCurrency = ‘EUR’;
AmountCur amountCur = 500.00;
AmountMst amountMST;
currencyExchangeHelper = CurrencyExchangeHelper::newExchangeDate(Ledger::current(), systemDateGet());
amountMST = currencyExchangeHelper.calculateTransactionToAccounting(transCurrency, amountCur ,true);
info(strFmt(‘%1’,amountMST));
}
Result :
calculateAccountingToTransaction
This method calculates the transaction currency amount from an accounting currency given.
static void SR_CEH_Example2(Args _args)
{
CurrencyExchangeHelper currencyExchangeHelper;
CurrencyCode transCurrency = ‘EUR’;
AmountCur amountCur;
AmountMst amountMST = 500.00;
currencyExchangeHelper = CurrencyExchangeHelper::newExchangeDate(Ledger::primaryLedger(CompanyInfo::findDataArea("DUM").RecId), systemDateGet());
amountCur = currencyExchangeHelper.calculateAccountingToTransaction(transCurrency, amountMST ,true);
info(strFmt(‘%1’,amountcur));
}
Result :
While searching through, I found that there are parmExchangeRate1 and parmExchangeRate2 methods that to calculate based on the exchange rates that have been provided. Please refer to the below example which calculates the misc charges [markup amount] based on the exchange rates defined.
Class Name : Markup >> calcMarkupAmount
Exploring more…will post soon!
Happy Dax6ng,
No comments:
Post a Comment