Number, Money, Percent

From RPM Wiki

Table of contents

Summary

There are various places in RPM where numbers are entered & displayed. This page covers the formatting rules for input and display of all three numerical data types:

  • Money
  • Percent
  • Number (integer)

Input

Places used

  • Money custom fields (manual & import)
  • Money data fields (manual & import)
  • Commission rates
  • Deposits
  • Commission items (manual & import)
  • Agency quotas
  • Reconciliation settings

Positive & negative

Money and percent amounts are saved as a signed real number. Integers are saved as signed integers. In other words, any of the three may be negative.

Decimal places

Money values will be rounded for display, but are always saved and calculated with up to four decimal places.

  • Validation: Limited to 4 decimal places maximum
  • Manipulation: Integers are rounded to the nearest whole number when saved.

Money validation

Examples of valid money values

$0
0
(0.0000)
.01
$.0001
($.1),
0.1
1.
1.00
1,000.00,
$1.00
$ 1.0000
-1.00
-$1,000.00,
-$ 1
$-1.00
$(1,000.00)
$ (1.00)
($1.00)
123,456,789,012.3456

This is the regular expression we use

/^\-?\(?\$?\s*\-?\s*\(?(((\d{1,3}((\,\d{3})*|\d*))?(\.\d{1,4})?)|((\d{1,3}((\,\d{3})*|\d*))(\.\d{0,4})?))\)?$/

Display formatting

Number, money, and percent values are always formatted for display.

Money

  • Preceded by a dollar sign.
  • Separate thousands with a comma. Example: $1,250.25
  • Shown to 2 or 4 decimal places depending on field option. Example: $50.00
  • If negative show red & in brackets. Example: ($50.00)

Percent

  • Followed by a percent sign.
  • Trim trailing zeros. Example: 50%
  • But show any decimals up to 2 if they exist. Example: 33.33%
  • Separate thousands with a comma. Example: 1,250.25%
  • If negative show red & precede with a dash. Example: -50%

Integer

  • Shouldn't be any decimal places. Example: 50
  • Separate thousands with a comma. Example: 1,250
  • If negative show red & precede with a dash. Example: -50

See also

  • This page was last modified 16:47, 22 Jun 2009.
  • This page has been accessed 915 times.