> For the complete documentation index, see [llms.txt](https://developer.esw.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.esw.com/salesforce-commerce-cloud/salesforce-commerce-cloud/pricing/core-price-construction/rounding-rules.md).

# Rounding Rules

The **ESW-SFCC cartridge** enables merchants to control how prices are displayed across the storefront, shopping cart, and ESW Checkout by configuring the **ESW Rounding Rules**.

These rules apply only to countries and currencies that use the **Calculated Pricing Model**.

## Implement Rounding Rules

Rounding behavior is configured within Salesforce B2C Commerce Business Manager. To define or modify rounding rules:

Navigate to `Merchant Tools → Custom Objects → Custom Object Editor → ESW_PA_DATA → ESW Rounding Rules`

Once configured, these rules will be applied automatically to all prices calculated via the ESW Pricing Advisor, ensuring consistent price presentation across the shopper journey.

### How Rounding Rules Are Applied

The ESW Rounding Rules are automatically applied to the appropriate country and currency after the `retailerPricingFeed` job is executed.

Below is a sample payload structure illustrating how rounding rules are assigned per country and currency:

{% code expandable="true" %}

```json
{
  "deliveryCountryIso": "GB",
  "roundingModels": [
    {
      "currencyIso": "GBP",
      "currencyExponent": 2,
      "direction": "Up",
      "model": "none.fixed99"
    }
  ]
},
{
  "deliveryCountryIso": "JP",
  "roundingModels": [
    {
      "currencyIso": "JPY",
      "currencyExponent": 0,
      "direction": "Nearest",
      "model": "multiple1000.none"
    }
  ]
}
```

{% endcode %}

<details open>

<summary>Rounding rule fields</summary>

**deliveryCountryIso** <mark style="color:$danger;">**required**</mark> `string`\
ISO code of the shopper’s delivery country.

***

**currencyIso** <mark style="color:$danger;">**required**</mark> `string`\
Currency to which the rounding rule applies. e.g., `GBP`, `JPY`

***

**currencyExponent** <mark style="color:$danger;">**required**</mark> `integer`\
Number of decimal places used. e.g., `2` for `GBP`.

***

**direction** <mark style="color:$danger;">**required**</mark> `enum`\
Rounding direction. Supported values: `Up`, `Down`, `Nearest`.

***

**model** <mark style="color:$danger;">**required**</mark> `string`\
Rounding model applied to product prices. e.g., `none.fixed99`, `multiple1000.none`.\
Supported methods: `Fixed`, `Multiple`, `None`.

</details>

### **Multiple Currency Rounding Rules per Country**

```json
{
  "deliveryCountryIso": "FR",
  "roundingModels": [
    {
      "currencyIso": "EUR",
      "currencyExponent": 2,
      "direction": "Up",
      "model": "none.none"
    },
    {
      "currencyIso": "GBP",
      "currencyExponent": 2,
      "direction": "Down",
      "model": "none.fixed99"
    }
  ]
}
```

## Model Rules

The following model rules govern how price values are adjusted based on the relationship between the currency exponent and the number of digits defined in the rounding model:

### **Truncate**

If the number of digits in the rounding model exceeds the number of digits allowed by the currency exponent, the extra digits are truncated.

### **Extend**

If the currency exponent allows more digits than the rounding model specifies, the model is extended with trailing zeros.

## Parameters and Values

| Parameter                       | Value   |
| ------------------------------- | ------- |
| Shipping country                | France  |
| Base currency                   | EUR     |
| Price book currency             | EUR     |
| Shopper currency                | GBP     |
| Product price in the price book | EUR 100 |
| Uplift                          | 3%      |
| Duty                            | 7%      |
| Tax                             | 20%     |
| FX Rate (EUR – GBP)             | 0.8313  |

Based on these values, the calculated price will be `109.9410876` GBP.

Calculated as: Price of product in price book x Uplift x Duty x Tax x FX rate\
\= `100 x 1.03 x 1.07 x 1.2 x 0.8313`\
\= `109.9410876`.

ESW rounding rules applied to the calculated price.

## Rounding rules and examples

### Rounding Method: `none`

```json
{"currencyIso":"GBP","currencyExponent":2,"direction":"Up","model":"none.none"}
```

Based on this, `109.9410876` GBP is displayed as `109.94` GBP on the storefront.

### Rounding Method: `fixed`

```json
{"currencyIso":"GBP", "currencyExponent":2, "direction":"Up", "model":"none.fixed25"}
```

Based on this, `109.9410876` GBP is displayed as `110.25` GBP on the storefront, and the shipping cost `27.49` is displayed as `28.25` GBP in the cart.

### Rounding Method: `multiple`

```json
{"currencyIso":"JPY","currencyExponent":0,"direction":"Nearest","model":"multiple1000.none"}
```

When the `multiple1000` rounding logic is applied, `14713/1000 = 14.7 > Nearest > 15 > 15 x 1000`\
\= `15000`

> The difference in product prices before and after the rounding model is applied is recorded at the order product line item level as the **ESW Delta Rounding Value**.

## ESW Rounding Rules Matrix

| Currency Exponent | Direction | Exponent Rounding (Fixed) | Exponent Rounding (Multiple) | Exponent Rounding (None) | Whole Number Rounding (Fixed) | Whole Number Rounding (Multiple) | Whole Number Rounding (None) |
| ----------------- | --------- | ------------------------- | ---------------------------- | ------------------------ | ----------------------------- | -------------------------------- | ---------------------------- |
| 0                 | Up        | N/A                       | N/A                          | N/A                      | Supported                     | Supported                        | Supported                    |
| 0                 | Down      | N/A                       | N/A                          | N/A                      | Supported                     | Supported                        | Supported                    |
| 0                 | Nearest   | N/A                       | N/A                          | N/A                      | Supported                     | Supported                        | Supported                    |
| 2                 | Up        | Supported                 | Supported                    | Supported                | Supported                     | Supported                        | Supported                    |
| 2                 | Down      | Supported                 | Supported                    | Supported                | Supported                     | Supported                        | Supported                    |
| 2                 | Nearest   | Supported                 | Supported                    | Supported                | Supported                     | Supported                        | Supported                    |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://developer.esw.com/salesforce-commerce-cloud/salesforce-commerce-cloud/pricing/core-price-construction/rounding-rules.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
