How to convert Amount in Accounting currency in Ax 2012

To convert Amount in Accounting currency in Ax 2012 you can take help of below code, first you need to find accounting currency then you can pass the value of currency using method calculatecurrencytocurrency .
Here an example to convert delivery remainder to accounting currency.

  Ledger         ledger;  
   Currencycode      accCurrency;  
   CurrencyExchangeHelper currencyExchangeHelper;  
   AmountMst        amountMST;  
   select ledger  
     where ledger.PrimaryForLegalEntity == CompanyInfo::findByCompany_IN(curext()).RecId;  
   accCurrency       = ledger.AccountingCurrency;  
   currencyExchangeHelper = CurrencyExchangeHelper::newExchangeDate(Ledger::current(), systemDateGet());  
   amountMST        = currencyExchangeHelper.calculateCurrencyToCurrency(this.CurrencyCode , accCurrency ,1 , true);  
   return this.SalesPrice * this.RemainSalesPhysical * amountMST;  

No comments: