Skip to main content

Show the amount in words

Print the total of a document in words, such as under the totals of an invoice. The example uses the Invoice document type and the NumberToText function.

Before you begin​

  • Open the designer from a saved invoice, on a template you may change. See Design an advanced report.
  • Know which currency the amount is in. The program gives the report a hidden parameter named CurrencyId, but what it holds depends on the window that prints: windows that have a currency box (bills, orders, Journal Entry, vouchers, Commercial Papers, notes and others) pass the currency chosen in the window, and other types (Point of Sale, restaurants, manufacturing, shipping, assets and others) pass the default currency of the program. The packing list, and a transfer printed from the transfers print window, pass no CurrencyId at all. The full list is in Advanced printing data sources.
  • On invoices, the columns of the invoice header that end with _ic hold the amounts divided by the currency value of the invoice, so they are in the currency of the invoice. GrandTotal_ic is calculated from the total, the extras and the discounts of the invoice; the procedure does not add the VAT column to it (VAT_ic is a separate column). Use GrandTotal_ic with CurrencyId on an invoice. See Advanced printing data sources.

Steps​

  1. Add a label to the Report Footer band, near the totals.

  2. Select the label. In the Properties panel, open the Expressions tab and click the expression button of the Text property.

  3. In the Expression Editor, build this expression:

    NumberToText([GrandTotal_ic], [Parameters.CurrencyId])

    Insert each name by double-clicking it in the lists of the editor: GrandTotal_ic from the "Bill" table of the field list, and CurrencyId from the parameters. The editor writes the path the band needs. The function has two operands: the amount, and the currency as its identifier. The editor refuses a second operand that is not a currency identifier.

  4. Click Ok, then click the Preview tab.

  5. Click Save.

Result​

The label prints the whole part of the amount in words, then the currency name, then the fractional part in words with the name of the currency part, such as the cents of a dollar. The wording follows the language the program runs in, not the template:

Program languageWhat is added around the words
ArabicThe word «فقط» before, and «لا غير» after. The currency names come from the currency card.
EnglishThe word "Only" after. The Latin names of the currency and its part are used when the card has them.

The fractional part prints only when it is more than zero. Its length follows the part precision of the currency.

If something goes wrong​

SituationWhy it happensWhat to do
The label shows <Currency not found: …>.The identifier does not belong to a currency in the file.Use [Parameters.CurrencyId] on a document that passes it, or a field that holds a currency identifier. A packing list passes none.
The words do not match the printed total.The amount used is not in the currency of the invoice.Use the _ic column, such as GrandTotal_ic, not GrandTotal. On a type that passes the default currency, the words follow that currency.
The expression is not accepted.The first operand is not a number, or the second is not an identifier.Check both operands in the Expression Editor.

This page applies to alameen ERP 10, version 10.1.79.764.