Convert amount to words in a transaction record

Inorder to display the amount in words, the following code can be used in transaction records:

<span style="color: black; font-weight: bold;">
    ${record.currency} ${total_tax_amount?string("c")} Only
</span>

${record.currency}:

  • FreeMarker Expression: Dynamically retrieves the currency value from the record object.
  • Example Output: USD or INR.

${total_tax_amount?string("c")}:

  • FreeMarker Expression with Formatting:
  • total_tax_amount: A variable that holds the total tax amount.
  • ?string("c"): Formats the tax amount as a currency string in the system’s locale.
  • Example Input: 1234.567
  • Example Output: 1,234.57 (formatted with commas and two decimal places).

If the variables have the following values:

  • record.currency = "USD"
  • total_tax_amount = 1234.567

The rendered output would look like this:

<p>

    Tax Amount (in words):
    <span style="color: black; font-weight: bold;">
        USD 1,234.57 Only
    </span>
</p>

Rendered View:

Tax Amount (in words): USD 1,234.57 Only

Leave a comment

Your email address will not be published. Required fields are marked *