Sunday, 7 June 2015

Currency Conversion in Ax through X++ Code

static void CurrencyConversion(Args _args)
{
   CurrencyExchHelper currencyExchangeHelper;
   AmountMst amountMST;
   CurrencyCode transCurrency;
   AmountCur amountCur;
   ;
   amountCur = 5000.00;
   currencyExchangeHelper = CurrencyExchHelper::newExchDate(“KSI”,”USD”,systemDateGet());
   amountMST = currencyExchangeHelper.calculateAmountCurToMst(amountCur ,true);
   info(strFmt(“%1″,amountMST));
}
In Ms Dynamics Ax 2012
static void SR_CEHConversion(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));
}