- Documentation Portal
- SDK and API
- General API Reference
- Browsing Support Methods
- RoundingRules
RoundingRules
Returns the list of rounding rules, optionally filtered by currency and country
Method/URL
https://{server_name}/Browsing/RoundingRules
Parameters
Request
Parameter Name | Type | Description | Mandatory |
|---|---|---|---|
| String | 2-char ISO country code. If not specified, rounding rules for all the countries supported by the Merchant will be returned | No |
| String | 3-char ISO currency code. If not specified, rounding rules for all the currencies supported by the Merchant will be returned | No |
Response
Parameter Name | Type | Description | Mandatory |
|---|---|---|---|
| List of | Returns list of rounding rules for currency. |
RoundingRule
Parameter Name | Type | Description | Mandatory |
|---|---|---|---|
| String | 2-char ISO country code | |
| String | 3-char ISO currency code | |
| List of | List of decimal ranges and their respective rounding behavior. | |
| Decimal | Rule identifier denoting the respective Rounding Rule on the Global‑e side. This value must be further specified when calling |
RoundingRange
Parameter Name | Type | Description | Mandatory |
|---|---|---|---|
| Decimal | A decimal value of the range start, exclusive of the | |
| Decimal | A decimal value used to calculate the target rounded value, for the numbers less than the | |
| Decimal | One of the possible values of | |
| List of | List of decimal values used to calculate the exceptions for rounding, i.e. values not to apply rounding for. | |
| Decimal | A decimal value required for the “nearest target” and “relative whole target” behavior. | |
| Decimal | A decimal value used to split the range so that the values less than the threshold would be rounded to the Lower target, and values greater than or equal to the threshold would be rounded to the Upper target. For the "Absolute target," the threshold range is an absolute value. Other Ranges are Relative values. See the absolute target in Rounding Range for more information. RoundingRange | |
| Decimal | A decimal value of the range end, inclusive. | |
| Decimal | A decimal value used to calculate the target rounded value, for the numbers greater than or equal to the Threshold, according to the defined Range behavior. If the |
Table 1: RoundingException
List of decimal values used to calculate the exceptions for rounding, i.e. values not to apply rounding for.
RangeBehaviors enumeration:
RangeBehaviors Option Value | Name | Description |
|---|---|---|
1 | Absolute target | In this behavior all the values within the specified range ( Getting rounding result (R) for the source number (S) must be implemented as follows: If (S = Exceptionn) then R = Exceptionn If (S < Threshold) then R = LowerTarget If (S >= Threshold) then R = UpperTarget |
2 | Relative Decimal target | In this behavior all the values within the specified range ( For source number (S): B = whole part of S LowerTarget (absolute): LA = B – 1 + LowerTarget UpperTarget (absolute): UA = B + UpperTarget Threshold (absolute): TA = B + Threshold Exceptionn (absolute): EAn = B + Exceptionn If (S = EAn) then Result (R) = EAn If (S < TA) then R = LA If (S >= TA) then R = UA |
3 | Relative Whole target | In this behavior LL the values within the specified range ( Getting rounding result (R) for the source number (S) must be implemented as follows: For source number (S): B = S rounded down to the closest multiple of V For example if (S = 56789 and V = 1000) then B = 56000 LowerTarget (absolute): LA = B – V + LowerTarget UpperTarget (absolute): UA = B + UpperTarget Threshold (absolute): TA = B + Threshold Exceptionn (absolute): EAn = B + Exceptionn If (S = EAn) then Result (R) = EAn If (S < TA) then R = LA If (S >= TA) then R = UA |
4 | Nearest target | In this behavior, Getting rounding result (R) for the source number (S) must be implemented as follows: For source number (S): B = S rounded down to the closest multiple of V For example, if (S = 123 and V = 5) then B = 120 LowerTarget (absolute): LA = B – 1 + LowerTarget UpperTarget (absolute): UA = B – 1 + V + UpperTarget Threshold (absolute): TA = B + Threshold Exceptionn (absolute): EAn = B + Exceptionn If (S = EAn) then Result (R) = EAn If (S < TA) then R = LA If (S >= TA) then R = UA |
Important Notices
If the result of rounding is a negative number, it must be set to zero, for any rounding behavior defined in the table above.
If either LowerTarget or UpperTarget value violates MaxDecimalPlaces setting for the respective currency, this value must be truncated accordingly. For example, if UpperTarget is set to 0.999 for USD, it must be truncated to 0.99 before using in any further calculations.
Table 2: Rounding Rules Samples
The following samples indicate how rounding X to Y (X → Y) is implemented using the respective settings.
0.25 → 0 3 → 0 1.5 → 1.5 2 → 2 | 22.47 → 21.95 22.48 → 22.99 22.50 → 22.50 33.75 → 33.75 | 2047 → 1995 2048 → 2100 | 122.26 → 124.99 122.25 → 119.99 127.26 → 129.99 121.50 → 121.50 127.50 → 127.50 123 → 123 128 → 128 | 2047 → 1999 2048 → 2100 | |
|---|---|---|---|---|---|
From | 0 | 1 | 1000 | 100 | 1000 |
To | 3 | 250 | 10000 | 1000 | 10000 |
Threshold | 3.01 | 0.48 | 48 | 2.26 | 48 |
LowerTarget | 0 | 0.95 | 95 | 0.99 | 0 |
UpperTarget | 0 | 0.99 | 100 | 0.99 | 1 |
RangeBehavior | 1 Absolute | 2 Relative Decimal | 3 Relative Whole | 4 Nearest | 4 Nearest |
TargetBehaviorHelperValue | 100 | 5 | 100 | ||
RoundingExceptions | 1.5 | 0.50 | 1.50 | ||
2 | 0.75 | 2.50 | |||
3 |
RoundingException
Parameter Name | Type | Description | Mandatory |
|---|---|---|---|
| Decimal | A decimal value to avoid rounding for. Rounding exceptions always behave like “Relative Decimal” |