Skip to main content

Show amounts in two currencies

Print the same amount twice: in the main currency of the file and in the currency of the invoice, with the exchange rate that was used. The example uses the Invoice document type and the functions ToPrice and ToExchangeRate.

Before you begin​

  • Open the designer from a saved invoice, on a template you may change. See Design an advanced report.
  • Use an invoice in a foreign currency to check the result. In the "Bill" table of the field list (the invoice header), Total is the amount before conversion, Total_ic is the same amount divided by the currency value of the invoice, and CurrencyVal is that currency value. The "Bill Items" table has columns with the same names, calculated for each line; this page uses the header.
  • The "Currency" table of the field list holds the currency card of the invoice, with Code and Name.

Steps​

  1. Under the table of the items, add two labels for the two totals, and two labels beside them with the captions Total (main currency) and Total (invoice currency).

  2. In the first total label, set the Text expression to ToPrice([Total]). In the Expression Editor, double-click Total under the "Bill" table of the field list.

  3. In the second total label, set it to ToPrice([Total_ic]), with Total_ic from the "Bill" table.

  4. Add a label for the rate, with the expression ToExchangeRate([CurrencyVal]). Take CurrencyVal from the "Bill" table.

  5. Add a label for the currency name. Drag the field Name of the "Currency" table of the Field List onto the band.

  6. Click the Preview tab, then click Save.

Result​

ToPrice writes the amounts with the number of decimals set for prices, and ToExchangeRate writes the rate with the number of decimals set for the exchange rate. Both are set in Program Options > Numbers, under Decimal Places. For an invoice in US Dollar at the rate 3.76:

FieldExpressionPrinted
Total in the main currencyToPrice([Total])3,760.00
Total in the invoice currencyToPrice([Total_ic])1,000.00
RateToExchangeRate([CurrencyVal])3.76

An invoice in the main currency has the rate 1, so both totals show the same amount.

If something goes wrong​

SituationWhy it happensWhat to do
The rate shows too few decimals.The decimals of the exchange rate are set to a small number.Change Rate under Decimal Places in Program Options > Numbers.
The expression is refused.The function takes a number, and the field is text.Check the field type in the Field List.
Both totals show the same amount.The invoice is in the main currency.Check with an invoice in a foreign currency.

This page applies to alameen ERP 10, version 10.1.79.764.