This code converts the specified amount from one currency to another using the exchange rates configured in the system, as shown in the images below.
public Amount getExchangeRateCurrency(Amount _amount)
{
CurrencyExchangeHelper currencyExchangeHelper;
CurrencyCode toCurrency= SystemParameters::find().SystemCurrencyCode;
TaxAmount taxAmount;
currencyExchangeHelper = currencyExchangeHelper::construct();
currencyExchangeHelper.parmLedgerRecId(Ledger::current()); //gets the current company
currencyExchangeHelper.parmExchangeRateTypeRecId(Ledger::budgetExchangeRateType()); // gets the budget rate type
return currencyExchangeHelper.calculateCurrencyToCurrency(fromCurrencyCode,toCurrency,_amount, true);
}
-------------------------------
Reference blog :
No comments:
Post a Comment