Thursday, March 17, 2016

Code to convert amount as per currency exchange rate

Below code can be used to apply exchange rate for the amount. From currency and To currency must be mentioned along the amount to be converted.



CurrencyExchangeHelper     currencyExchangeHelper;
AmountCur                           amountValue = 100;
AmountMst                         amountMST;
CurrencyCode                       fromCurrency = 'SAR', toCurrency = 'USD';
 
currencyExchangeHelper = CurrencyExchangeHelper::newExchangeDate(Ledger::current(), systemDateGet());
amountMST                    = currencyExchangeHelper.calculateCurrencyToCurrency(fromCurrency, toCurrency, amountValue, false);  

info(strfmt("%1", amountMST));

No comments:

Post a Comment