Examples of rounding
This reference provides a detailed example of how rounding works.
For example, a fictitious SaaS company sells seat licenses to its software and charges for any storage used. It offers the following monthly rate plan for its product:
Recurring Fee |
Usage Fee |
---|---|
$59.99/seat license per month |
$1/GB per month |
It has defined the following units of measure:
Unit of measure |
Number of decimal places |
Rounding rule |
---|---|---|
Seat License |
0 |
Round down |
Gigabytes |
2 |
Round down |
The company also charges sales tax at the rate of 7.775%. A subscription is then created and a quantity of 4.6 is mistakenly entered for the number of seat licenses. Since seat licenses have 0 decimal places and transaction quantities are rounded prior to being stored, 4.6 is rounded to 4 based on its round down rounding rule, and then stored. Any query via the API or display of this value in the UI will return a value of 4.
The usage is subsequently uploaded into the system with a value of 12.31245 GB. Since usage quantity is stored as is, the value 12.31245 is then stored. Any display in the UI or query via the API will return the value of 12.31245. When the invoice is generated, charges are calculated as defined in the following table:
Amount |
Calculation |
Total |
---|---|---|
Recurring Charge |
Unit price * transaction quantity = $59.99/seat license * 4 seat licenses |
$239.96 |
Usage Charge |
Unit price * usage quantity = $1/GB * Round(12.31245 GB)= $1/GB * 12.32 GB ) |
$12.32 |
Tax item on recurring charge |
Charge * tax rate = $239.96 * 0.0775 |
$18.5969 |
Tax item on usage charge |
UCharge * tax rate = $12.32 * 0.0775 |
$0.9548 |
Invoice Total |
Recurring charge + usage charge + total tax = $239.96 + $12.32 + $19.55 |
$271.83 |
Usage quantities (like GB) are not rounded when stored, while transaction quantities (like seat licenses) are rounded when stored. For example, 12.3124 GB is not rounded, while 4.6 seat licenses are stored as 4 seat licenses. Individual tax items are not rounded. When they are aggregated (added together) for a total tax they are then rounded.