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 :

image

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 :

image

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

image

Exploring more…will post soon!

 

Happy Dax6ng,

 

sree

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: