Rounding
Rounding sets the final price of an item: the price including VAT or, for a profile set to round it, the price excluding VAT. It is applied only after every other step of the price calculation (VAT, inheritance, bundles and scheduled updates). Rounding is designed to be simple, predictable and suitable for both B2B and B2C.
A small set of options covers the vast majority of real-world pricing needs.
Why rounding is useful
Rounding ensures that prices:
- follow consistent decimal rules across markets and currencies
- meet compliance requirements
- use predictable price increments
- can follow common charm-price patterns, such as .99 and .95
- carry no stray decimals from upstream systems
You can set profiles at different levels, so you can round differently per market, currency or channel.
Rounding options
Rounding is defined by rounding profiles. Each profile consists of one or more tier rules, and each tier rule sets how prices in a range are rounded.
Rounding tier rules
Each tier rule sets the rounding for prices in one range, with these fields:
range_start(decimal): the lower bound of the tier's price range, inclusive.mode(enum): the rounding direction. One of:UP(round up)DOWN(round down)CLOSEST(round to the nearest value)NONE(do not round; only apply the offset)
decimals(nullable integer, from -6 to 4): the number of decimals to round to: 2 rounds to cents, 0 to whole units and -1 to tens. If null, the price is rounded byincrement. Text such as"2"is also accepted.increment(nullable decimal): the increment to round to, such as 0.05. If null, the price is rounded bydecimals.offset(decimal): an amount added or subtracted after rounding, such as -0.01 for charm prices.
When both decimals and increment are set, a positive increment takes precedence. With neither, the price is not rounded, but offset is still added. A tier without a mode does not round (NONE).
Tiers let you define complex rounding schemes in a clear, maintainable way.
There is no range_end. A tier's range ends at the next higher range_start, and the tier with the highest
range_start covers every price above it. There are therefore no gaps between tiers.
The standard profile
Every new account starts with one rounding profile, standard. It is the global default and rounds every price,
including VAT, to two decimals, to the closest: 8.9012 becomes 8.90. A price converted to another currency or given a
percentage discount therefore has at most two decimals from your first query, before you have written a profile of your
own.
{
"code": "standard",
"default_global": true,
"vat_basis": "INC_VAT",
"rounding_tier_rules": [{ "range_start": 0, "mode": "CLOSEST", "decimals": 2 }]
}
It is an ordinary profile: edit it, make another profile the global default, or delete it. A currency without decimals,
such as JPY, needs a profile of its own, a currency default with decimals: 0, which applies before the global default.
If you delete the standard profile and set no other default, prices are not rounded.
An account created before the standard profile was introduced has none. Add it with the request above.
Default profiles
The rules for which profile applies are deliberately simple and explicit, so there are no silent fallbacks or surprises.
You can create any number of rounding profiles, each identified by its code. A profile applies in one of three ways:
- Global default: zero or one profile.
- Currency default: zero or one profile per currency.
- Chosen per request: any profile, named with
rounding_profile.
Profiles are never inherited, and a currency never falls back to another currency's profile.
Defaults are set on the profile itself:
{
"code": "sek-retail",
"currency_code": "SEK",
"default_for_currency": true,
"default_global": false,
"vat_basis": "INC_VAT",
"rounding_tier_rules": [{ "range_start": 0, "mode": "UP", "decimals": 0, "offset": -0.01 }]
}
| Field | Meaning |
|---|---|
default_for_currency with currency_code | The default profile for that currency |
default_global | The global default |
vat_basis | INC_VAT (default) rounds the price including VAT; EX_VAT rounds the price excluding VAT. See What is rounded |
valid_from | When this version takes effect. If absent or in the past, it takes effect now. See Scheduled updates |
remove_future_changes | true also removes the versions already scheduled after this one |
When you make a profile a default, the profile that held that role loses it from the new version's valid_from.
How the profile is chosen
Quantaprice chooses the profile as follows.
When the request names no profile
- If the requested currency has a default profile, it is used.
- Otherwise, the global default is used, if there is one.
- Otherwise, the price is not rounded.
When the request names a profile (for example, rounding_profile = "b2b")
- If a profile with exactly that code exists, it is used, even if it belongs to another currency.
- Otherwise, the requested currency's default profile is used, if there is one.
- Otherwise, the global default is used, if there is one.
- Otherwise, the price is not rounded.
As a result:
- behaviour is predictable,
- rounding never falls back to another currency's profile by accident,
- rounding does not depend on pricelists,
- there is no hidden or implicit rounding.
Evaluation order
Rounding is deterministic and always follows these steps:
- Choose the rounding profile (the request's, then the currency default, then the global default).
- Choose the tier whose range contains the unrounded price that the profile rounds: the price including VAT, unless the
profile's
vat_basisisEX_VAT. - Apply the tier: round by increment or decimals, then apply the offset.
- Calculate the VAT from the rounded price, to the currency's
vat_precision. From a price including VAT, the price excluding VAT is the remainder; to a price excluding VAT, the VAT is added.
The profile rounds the stored price exactly as it stands: the price on the list, or a quantity break's percent_of_base
multiple of it, converted at the exchange rate, with the VAT added or taken out, is not rounded on the way to the
profile. A stored price is therefore rounded once, at delivery. Without a profile, it is kept to four decimals.
A price that Quantaprice calculates when you write is stored with four decimals first, like any amount you write: the
result of a price rule, a bundle price and a price inherited
into a pricelist in another currency. That stored price is then rounded once at delivery, like any other. The two
roundings can differ from a single one in a ten-thousandth: a rule sales * 0.5 on 0.3699 is stored as 0.1850
(exactly 0.18495), which a profile rounding the price excluding VAT to two decimals makes 0.19, where 0.18495 alone
would have made 0.18.
What is rounded
By default, a rounding profile rounds the price including VAT, whether the pricelist is NET or GROSS, at the VAT
rate of the tax area in the query. The VAT is then calculated from the rounded price, and the price excluding VAT is the
remainder, so sales_price_ex_vat + vat_amount = sales_price_inc_vat always holds.
On a NET pricelist, the price excluding VAT can therefore differ from the price on the list. For example, with 25% VAT
and a profile that rounds up to a whole number and subtracts 0.01:
| Excluding VAT | VAT | Including VAT | |
|---|---|---|---|
Price on the NET list | 79.00 | 19.75 | 98.75 |
| Returned | 79.19 | 19.80 | 98.99 |
Use the returned prices and VAT amount as they are: if you add or remove VAT yourself, the result can be a cent out.
Rounding the price excluding VAT
A profile with vat_basis set to EX_VAT rounds the price excluding VAT instead, on NET and GROSS pricelists
alike. Its tiers are matched against the price excluding VAT, and the VAT is added to the rounded price.
Because each request can name its profile, one pricelist can serve both consumers and businesses. For example, with a
GROSS list price of 99.00, 25% VAT and two profiles that round up to a whole number and subtract 0.01:
| Profile | vat_basis | Excluding VAT | VAT | Including VAT |
|---|---|---|---|---|
b2c | INC_VAT (default) | 79.19 | 19.80 | 98.99 |
b2b | EX_VAT | 79.99 | 20.00 | 99.99 |
{
"code": "b2b",
"vat_basis": "EX_VAT",
"rounding_tier_rules": [{ "range_start": 0, "mode": "UP", "decimals": 0, "offset": -0.01 }]
}
Bundles
A bundle whose components have different VAT rates is rounded as a whole. The rounded price is divided between the components in proportion to their prices, including or excluding VAT as the profile rounds, and each component's VAT is calculated at its own rate. The bundle's VAT is therefore the VAT on the price charged.
Without a rounding profile, or for a price below the profile's lowest range_start, the price is not rounded.
This keeps results consistent, however complex the pricing that comes before rounding.
Example
A single tier rule that produces charm prices:
{
"range_start": 0,
"mode": "UP",
"decimals": 0,
"increment": null,
"offset": -0.01
}
This rule rounds prices up to a whole number and then subtracts 0.01, giving prices that end in .99 (for example,
12.30 → 13.00 → 12.99).
API reference
Rounding profiles are managed with the /rounding endpoints:
| Endpoint | Description |
|---|---|
GET /rounding | List every rounding profile |
POST /rounding | Create a rounding profile |
GET /rounding/{code} | Get a rounding profile |
PUT /rounding/{code} | Create or update a rounding profile by code |
DELETE /rounding/{code} | Delete a rounding profile |
POST /rounding/evaluate | Test a rounding profile against a list of values |
POST, PUT and DELETE return 200 with no body, and 400 for a missing code, an unknown mode or vat_basis, or decimals outside -6 to 4. GET /rounding and GET /rounding/{code} take asOf to read profiles as they were, or will be, at another moment.
POST /rounding/evaluate rounds a list of amounts with a profile that you send, without saving the profile, and returns the rounded amounts as a JSON array:
POST /rounding/evaluate
{
"values": [12.30, 0.50],
"profile": { "code": "test", "rounding_tier_rules": [{ "range_start": 1, "mode": "UP", "decimals": 0, "offset": -0.01 }] }
}
[12.99, 0.5]
The amounts are rounded as given: vat_basis has no effect here.
To apply a rounding profile to a price query, pass rounding_profile in the request body of POST /price/query, or as the rounding_profile query parameter of GET /price/{sku}/{pricelist}/{tax_area}.