Convert Currencies with SuiteScript
The Exchange Rate column of the Currency Exchange Rates record displays the company-wide exchange rates. To access the Currency Exchange Rates record, go to Lists > Accounting > Currencies.
You can access these values with the nlapiExchangeRate(sourceCurrency, targetCurrency, effectiveDate) API. For more information, see SuiteScript 1.0 API Reference.
Use the following example code to perform a conversion using the company–wide exchange rates:
function customizeGlImpact(transactionRecord, standardLines, customLines, book)
{
...
var amountToAdd = 20; // USD
var amountCurrency = 1; // internal id of USD currency in their account
var subsidId = transactionRecord.getFieldValue('subsidiary');
var bookId = book.getId();
var targetCurrency = getBaseCurrency(subsidId,bookId);
if(targetCurrency!=amountCurrency)
{
var rate = nlapiExchangeRate(amountCurrency,targetCurrency);
amountToAdd = amountToAdd * rate;
}
var newLine = customLines.addNewLine();
newLine.setDebitAmount(amountToAdd);
...
}