Ledger

Money Formatting

Reference for money formatting options for amounts in a Twisp Ledger.

The Basics

The Money type in Twisp represents a monetary amount. Fields of this type can be represented (via its formatted field) in various ways depending on the options provided in the MoneyFormatInput.

This reference provides a review of the different ways to format monetary amounts in Twisp, including formatting whole numbers, minimum and maximum digits, rounding modes, locales, grouping, currency minimum digits, and currency displays.

Unless otherwise indicated, all examples below use the en-US locale.

Minor Units

Setting the minDigits and maxDigits determines how many digits of the minor units to display. When minDigits not specified, it will use the default fractional digits for the currency.

UnitsCurrencyMin DigitsMax DigitsFormatted
9USDDEFAULTDEFAULT$9.00
9USDDEFAULT0$9
9USD0DEFAULT$9
9USD1DEFAULT$9.0
9USD2DEFAULT$9.00
9USD3DEFAULT$9.000
9.123456789USDDEFAULTDEFAULT$9.123457
9.123456789USDDEFAULT0$9
9.123456789USDDEFAULT0$9.1
9.123456789USDDEFAULT0$9.12
9.123456789USDDEFAULT0$9.123

Rounding

The roundingMode option defines the rounding behavior when the fractional units exceed the maxDigits.

UnitsCurrencyRounding ModeMax DigitsFormatted
9.005USDDOWN2$9.00
9.005USDHALF_DOWN2$9.00
9.005USDUP2$9.01
9.005USDHALF_UP2$9.01
9.006USDDOWN2$9.00
9.006USDHALF_DOWN2$9.01
9.006USDUP2$9.01
9.006USDHALF_UP2$9.01

Currency Display

Use the currencyDisplay to change the currency indicator.

UnitsCurrencyCurrency DisplayFormatted
12345.67USDDEFAULT$12345.67
12345.67USDCODEUSD 12345.67
12345.67USDNONE12345.67
12345.67USDSYMBOL$12345.67

Other Locales

Changing the locale option formats the amount according to the standards of that locale.

UnitsCurrencyLocale (Country)Formatted
123456789.123456789USDzh-CN (China)US$123456789.123457
123456789.123456789USDes-CO (Colombia)US$ 123456789,123457
123456789.123456789USDfr-FR (France)123456789,123457 $US
123456789.123456789USDde-DE (Germany)123456789,123457 $
123456789.123456789USDhi-IN (India)$123456789.123457
123456789.123456789USDja-JP (Japan)$123456789.123457
123456789.123456789USDar-AE (UAE)US$ 123456789.123457
123456789.123456789USDen-GB (UK)US$123456789.123457
123456789.123456789USDen-US (USA)$123456789.123457
123456789.123456789EURzh-CN (China)€123456789.123457
123456789.123456789EURes-CO (Colombia)€ 123456789,123457
123456789.123456789EURfr-FR (France)123456789,123457 €
123456789.123456789EURde-DE (Germany)123456789,123457 €
123456789.123456789EURhi-IN (India)€123456789.123457
123456789.123456789EURja-JP (Japan)€123456789.123457
123456789.123456789EURar-AE (UAE)€ 123456789.123457
123456789.123456789EURen-GB (UK)€123456789.123457
123456789.123456789EURen-US (USA)€123456789.123457

Grouping

When groupDigits is set to true, digits will be grouped according to the standards for each locale.

UnitsCurrencyLocale (Country)Formatted
123456789.123456789USDzh-CN (China)US$123,456,789.123457
123456789.123456789USDes-CO (Colombia)US$ 123.456.789,123457
123456789.123456789USDfr-FR (France)123 456 789,123457 $US
123456789.123456789USDde-DE (Germany)123.456.789,123457 $
123456789.123456789USDhi-IN (India)$12,34,56,789.123457
123456789.123456789USDja-JP (Japan)$123,456,789.123457
123456789.123456789USDar-AE (UAE)US$ 123,456,789.123457
123456789.123456789USDen-GB (UK)US$123,456,789.123457
123456789.123456789USDen-US (USA)$123,456,789.123457

Minimum Digits by Currency

The default setting for minDigits changes depending on which currency is used because different currencies have a different number of minor units used.

  • US dollars (USD) use 2 minor units (i.e. cents).
  • Jordanian Dinars (JOD) use 3 minor units.
  • Uganda Shillings (UGX) use no minor units.

UGX is the code for the Uganda shilling, which uses 0 minor units.

UnitsCurrencyFormatted
9USD$9.00
9JODJOD 9.000
9UGXUGX 9
Previous
Transactions