> ## Documentation Index
> Fetch the complete documentation index at: https://enterprise-docs.bglobale.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Rounding rules

> Returns the list of rounding rules for a merchant, optionally filtered by currency and country.

Returns the list of rounding rules, optionally filtered by currency and country

The `RangeBehavior` on each `RoundingRange` selects one of the behaviors below. Expand for the calculation logic, the important notices, and worked samples.

<AccordionGroup>
  <Accordion title="RangeBehaviors enumeration — calculation logic">
    **1 — Absolute target.** In this behavior all the values within the specified range (`LowerTarget`, `UpperTarget`, `Threshold` and `RoundingExceptions`) denote the values themselves as is, without the need for any additional math operations. 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 (`LowerTarget`, `UpperTarget`, `Threshold` and `RoundingExceptions`) represent floating point numbers between 0 (inclusive) and 1 (inclusive), used to calculate the respective absolute values, relative to the calculation base (B) as follows:

    ```
    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 ALL the values within the specified range (`LowerTarget`, `UpperTarget`, `Threshold` and `RoundingExceptions`) represent non-negative whole numbers, while `TargetBehaviorHelperValue` (V) is used to determine the calculation base (B). V must be a power of 10 (10, 100, 1000, etc.) and denotes the order of magnitude for the range "split" by the Threshold. For example, if Threshold = 9 we need to know if this is 9 out of 10 or 9 out of 100. 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, `LowerTarget` and `UpperTarget` represent non-negative floating-point numbers, while `TargetBehaviorHelperValue` (V) is used to determine the calculation base (B). V must be a whole divisor of any power of 10 (5, 10, 25, 50, 100, 250, 500, 1000, etc.). The threshold must be any floating-point number between 0 (inclusive) and V (exclusive). 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
    ```
  </Accordion>

  <Accordion title="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.
  </Accordion>

  <Accordion title="Rounding rules samples">
    The following samples indicate how rounding X to Y (X → Y) is implemented using the respective settings. Each numbered column is one settings scenario together with its sample results (re-extracted from the source table, preserving column alignment).

    | Setting                   | 1                                             | 2                                                                      | 3                            | 4                                                                                                                                 | 5                            |
    | ------------------------- | --------------------------------------------- | ---------------------------------------------------------------------- | ---------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | ---------------------------- |
    | Sample results (X → Y)    | 0.25 → 0<br />3 → 0<br />1.5 → 1.5<br />2 → 2 | 22.47 → 21.95<br />22.48 → 22.99<br />22.50 → 22.50<br />33.75 → 33.75 | 2047 → 1995<br />2048 → 2100 | 122.26 → 124.99<br />122.25 → 119.99<br />127.26 → 129.99<br />121.50 → 121.50<br />127.50 → 127.50<br />123 → 123<br />128 → 128 | 2047 → 1999<br />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, 2                                        | 0.50, 0.75                                                             |                              | 1.50, 2.50, 3                                                                                                                     |                              |
  </Accordion>
</AccordionGroup>


## OpenAPI

````yaml api-reference/specs/roundingrules.yaml POST /Browsing/RoundingRules
openapi: 3.0.3
info:
  title: RoundingRules
  version: 1.0.0
  x-scaled-review: true
  description: >-
    Returns the list of rounding rules, optionally filtered by currency and
    country
servers:
  - url: https://{globale_api_domain}
    variables:
      globale_api_domain:
        default: globale_api_domain
        description: Global-e API host, supplied to the merchant by Global-e.
security: []
tags:
  - name: RoundingRules
    x-page-title: RoundingRules
  - name: 'Direction: Merchant → Global-e'
  - name: 'Domain: Browsing & Catalog'
paths:
  /Browsing/RoundingRules:
    post:
      tags:
        - RoundingRules
      summary: >-
        Returns the list of rounding rules, optionally filtered by currency and
        country
      description: >-
        Returns the list of rounding rules, optionally filtered by currency and
        country
      operationId: roundingRules
      parameters:
        - name: countryCode
          in: query
          required: false
          description: >-
            2-char ISO country code. If not specified, rounding rules for all
            the countries supported by the Merchant will be returned
          schema:
            type: string
        - name: currencyCode
          in: query
          required: false
          description: >-
            3-char ISO currency code. If not specified, rounding rules for all
            the currencies supported by the Merchant will be returned
          schema:
            type: string
      responses:
        '200':
          description: List of rounding rules.
          content:
            application/json:
              schema:
                type: object
                properties:
                  RoundingRule:
                    type: array
                    description: Returns list of rounding rules for currency.
                    items:
                      $ref: '#/components/schemas/RoundingRule'
components:
  schemas:
    RoundingRule:
      type: object
      title: RoundingRule
      properties:
        CountryCode:
          type: string
          description: 2-char ISO country code
        CurrencyCode:
          type: string
          description: 3-char ISO currency code
        RoundingRanges:
          type: array
          description: List of decimal ranges and their respective rounding behavior.
          items:
            $ref: '#/components/schemas/RoundingRange'
        RoundingRuleId:
          type: number
          description: >-
            Rule identifier denoting the respective Rounding Rule on the
            Global‑e side. This value must be further specified when calling
            SaveProductsList and SendCart methods
    RoundingRange:
      type: object
      title: RoundingRange
      properties:
        From:
          type: number
          description: >-
            A decimal value of the range start, exclusive of the From value
            itself. If a range must start from 0 inclusive, the From value must
            be set to a negative number.
        LowerTarget:
          type: number
          description: >-
            A decimal value used to calculate the target rounded value, for the
            numbers less than the Threshold , according to the defined Range
            behavior. If the LowerTarget value violates the MaxDecimalPlaces
            setting for the respective currency, it must be truncated as
            described in the “ Important Notices ” below.
        RangeBehavior:
          type: number
          enum:
            - 1
            - 2
            - 3
            - 4
          description: >-
            One of the possible values of RangeBehaviors enumeration defined
            below which is designed to control the way rounding range is
            handled. The range behavior is applied to Threshold , LowerTarget ,
            UpperTarget and Exceptions in the RoundingExceptions list.
        RoundingExceptions:
          type: array
          description: >-
            List of decimal values used to calculate the exceptions for
            rounding, i.e. values not to apply rounding for.
          items:
            $ref: '#/components/schemas/RoundingException'
        TargetBehaviorHelperValue:
          type: number
          description: >-
            A decimal value required for the “nearest target” and “relative
            whole target” behavior.
        Threshold:
          type: number
          description: >-
            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.
        To:
          type: number
          description: A decimal value of the range end, inclusive.
        UpperTarget:
          type: number
          description: >-
            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 UpperTarget value violates the
            MaxDecimalPlaces setting for the respective currency, it must be
            truncated as described in the “Important Notices” below.
    RoundingException:
      type: object
      title: RoundingException
      properties:
        ExceptionValue:
          type: number
          description: >-
            A decimal value to avoid rounding for. Rounding exceptions always
            behave like “Relative Decimal”

````