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),
Totalis the amount before conversion,Total_icis the same amount divided by the currency value of the invoice, andCurrencyValis 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
CodeandName.
Steps
-
Under the table of the items, add two labels for the two totals, and two labels beside them with the captions
Total (main currency)andTotal (invoice currency). -
In the first total label, set the Text expression to
ToPrice([Total]). In the Expression Editor, double-clickTotalunder the "Bill" table of the field list. -
In the second total label, set it to
ToPrice([Total_ic]), withTotal_icfrom the "Bill" table. -
Add a label for the rate, with the expression
ToExchangeRate([CurrencyVal]). TakeCurrencyValfrom the "Bill" table. -
Add a label for the currency name. Drag the field
Nameof the "Currency" table of the Field List onto the band. -
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:
| Field | Expression | Printed |
|---|---|---|
| Total in the main currency | ToPrice([Total]) | 3,760.00 |
| Total in the invoice currency | ToPrice([Total_ic]) | 1,000.00 |
| Rate | ToExchangeRate([CurrencyVal]) | 3.76 |
An invoice in the main currency has the rate 1, so both totals show the same amount.
If something goes wrong
| Situation | Why it happens | What 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. |
Related
This page applies to alameen ERP 10, version 10.1.79.764.