Skip to content
ericfoy edited this page Jul 2, 2023 · 14 revisions

Formatting Options

Though the formatting options are pretty self explanatory, here is a more in-depth description of each:

Use parentheses for negative values:

Sometimes, (particularly in the field of accounting) it is desirable to present negative values in parentheses, rather than indicating negativity with the sign (-) itself. Selecting this option will render, e.g., "-32.54" as "(32.54)".

Text to display for Zero Value:

Sometimes you might want your zero values to stand out as distinct exceptions in their field. For instance, you may want to specify "-0-" or "[zero]".

There is also a case wherein you need to specify something here in order to avoid a blank or null display in the case of zero (see Trim Trailing Decimal Point option below).

Of course, it's conversely possible to ensure a blank display for all zeros, by inputting a 'space' here.

Thousands Marker / Decimal Marker

These are quite self-explanatory, and they work the same as always (without this module being installed).

Max. Decimal Places

This is the maximum number of decimal places to be displayed. Note that this is essentially the same selector as the one labelled "Scale" in the default formatter prior to installing this module. The reason we do not call this "Scale" is two-fold:

  1. The use of the term "scale", though conventional in programming circles, is actually mathematically inappropriate. "Precision" would be a more appropriate descriptor.
  2. The term "Scale" is also used in the field definition dialog, and in that context it is being used to determine the precision at which the value is stored in the database. This is a separate issue to that of determining how to display the value in any given output context.

Min. Decimal Places

This parameter is used only if you also select "Suppress Trailing Zeros" below...

Suppress Trailing Zeros

A typical use case: You have a "price each" column which is multiplied by a "Quantity" column to arrive at an "extended price." This is very common for documents such as invoices, sales orders, etc.

In this scenario it is generally desirable to display currency values with at least two decimal places (e.g., "$.10" in the case of ten cents — or "£.20" in the case of twenty p)—because $.1 and £.2 just don't look right.

If, however, the price of the item is "$105.60 per 1,000 pieces," then the price each is "$.1056," which should be displayed not as "$.11" but as "$.1056" so that the math actually "adds up."

And yet, you may not want to bore everyone with a pedantic display of "price each" values of "$12.0000," "$.2000," etc. So to avoid displaying a sea of zeros unnecessarily, you may set Min. Decimal Places to 2, and select "Suppress Trailing Zeros."

With this module you are able to set up your column to display all of the following values, as appropriate, according to the rules you set up:

  • $ 1.4300 -> $1.43
  • $ 1.4000 -> $1.40
  • $ 1.0000 -> $1.00
  • $ 0.3723 -> $.3723
  • $ 0.3720 -> $.372
  • $ 0.3700 -> $.37
  • $ 0.3000 -> $.30

Suppress Leading Zero before Decimal

Select this option if you want to display "0.013" as simply ".013"

Suppress decimal point for integer value

In the case where both

  1. Min. Decimal Places is zero, AND
  2. Suppress trailing zeros is selected

then a value such as "12.000" will display as "12." If, instead, you want it displayed as "12" then select this option.

The caveat! Zero display.

Note that if the following options are selected:

  1. Trim Leading Zero AND
  2. Min. Decimal Places = 0 AND
  3. Suppress Trailing Zeros AND
  4. Suppress Trailing Decimal

Then "0.000" becomes ".000" which becomes "." which becomes "" — a null display for a zero value.

This may, in fact, be the desired behavior, but in order to avoid this situation you must provide a value in "Text to display for zero value."

Note that the value of the field, behind the scenes, remains simply 0 (zero—a mathematical value). You are simply telling the display processor what to show us for that value. So a simple "0" might be all that you require.

Of course, you can supply any string, such as "0.00," et al., as the formatting rules do not apply to this string.

A Note regarding Scale

When defining a number field, you are choosing how the data field is to be stored in the database. This definition also determines how the validation rules work for the input form(s). In the case of a decimal field, one of the options is "scale," which determines how many decimal places will be stored with the value. Then the standard (core) display options offer you the choice of "scale" (number of decimal places) with which to display the field's value. This can be a bit confusing.

The point of interest here is that the endo module doesn't do any validation of the display settings, so it's possible to select to display 6 decimal places even for a field which is stored with a scale of 2. If you do this, you will always see at least four trailing zeros (unless you select to trim trailing zeros, which would be rather pointless).

I have adopted the practice of defining my decimal fields with a scale of at least 2 more places than I will ever display. This way I know that the value will not lose accuracy due to rounding errors.