Transaction-Specific Exchange Rates

If a user can define transaction-specific exchange rates for the accounting book on a transaction, you can use the conversion rate for the accounting book to perform the conversion.

The following screenshot shows the Exchange Rate on the Accounting Books subtab of a Cash Sale transaction:

Exchange rate shown on the transaction.

Use the following example code to find the exchange rate by accessing the exchange through the Record object:

             function customizeGlImpact(transactionRecord, standardLines, customLines, book)
   {
      ...
      var amountToAdd = 20; // Amount in Primary book's currency
      
      if (!book.isPrimary()) // Amount is in Primary book's currency, convert only for non-primary books
      {
         var bookId = book.getId();
         
         for (var line = 1; line <= transactionRecord.getLineItemCount('accountingbookdetail'); line++) 
         {
            if (bookId == transactionRecord.getLineItemValue('accountingbookdetail','bookid',line))
            {
               var rate = transactionRecord.getLineItemValue('accountingbookdetail','exchangerate',line);
               amountToAdd = amountToAdd * rate;        

            break;
            }
         }
      }
      var newLine = customLines.addNewLine();
      newLine.setDebitAmount(amountToAdd);
      ...
   } 

        

Related Topics

Multiple Currencies Examples
Find the Base Currency
Base Currency from Accounting Book Record
Convert Currencies with SuiteScript

General Notices