How totals are calculated

See exactly how Commerce turns line prices into the final total: price rules, discounts, fees, tax, surcharges and rounding, with a fully worked example.

In plain words: The total on a quote is not magic. Commerce always works in the same order: it prices each line, subtracts discounts, adds fees, works out tax, and last adds surcharges. This page shows that order, explains the two settings that change it (how discounts stack and where rounding happens), and walks through one quote with every number. Read it when a total surprises you, or before you set up discounts, taxes and fees. New to the words? See Commerce basics.

Where to find it: this is a reference page. The totals appear at the bottom of the lines on a quote or order, under Customer pays. The two settings are in Commerce > left icon rail > Settings > Services > open a quote service > Pricing. Who can use it: everyone reads totals. Admins change the Pricing settings. An order or invoice made from a quote is priced again by its own service, using the standard choices, so set your quote service to those if you want the same total on every document.

Why the order matters

The same pieces in a different order give a different total. A 10% discount before tax is worth less than the same percentage after tax, and a card surcharge on the price alone is smaller than one on the price plus tax. Commerce fixes the order so every quote, order and invoice of a service is worked out the same way, and so the numbers match what an accountant expects.

The order of calculation

Step

What happens

Where it is set up

1. Line price

Quantity times unit price. A price rule may lower the unit price first. A line can also carry its own line discount

Price rules, Discounts

2. Discounts on the whole quote

One or more discounts come off the subtotal

Discounts

3. Fees before tax

Shipping, handling and similar. They can be taxable

Taxes and fees

4. Tax

Worked out on what is left after discounts, plus taxable fees

Taxes and fees

5. Surcharges after tax

For example a card payment charge. Never taxed, never discounted

Taxes and fees

6. Rounding

Amounts become whole cents, per line or once per document

Pricing settings

1. Line price

A line's amount is its quantity times its unit price. If the line is sold for a term (for example 12 months), the amount covers the whole term, see Quote options and terms.

A price rule attached to the price entry can lower the unit price before anything else. With a rule that gives 90 per unit from 10 units, 10 units at a list price of 100 become 10 x 90 = 900. The rule's saving is already inside the unit price. It is never subtracted a second time.

A line discount is taken off that line only, as a percentage or a fixed amount. It can never push a line below zero. The subtotal is the sum of all line amounts after line discounts.

2. Discounts on the whole quote

A whole-quote discount comes off the subtotal. It can never be larger than the subtotal. When you apply more than one, the Discount stacking setting decides how they combine.

Parallel (the default). Every discount is taken from the same starting amount. Two discounts of 10% and 5% on 1,300 take 130 and 65: 195 in total, so 1,105 remain. Percentages simply add: 10% + 5% = 15%.

Sequential. Each discount is taken from what the previous one left. 10% off 1,300 is 130, leaving 1,170. Then 5% of 1,170 is 58.50, so 188.50 comes off in total and 1,111.50 remain. Two 10% discounts on 100 take 10, then 9: 19% off, not 20%.

Parallel

Sequential

10% then 5% on 1,300

130 + 65 = 195 off

130 + 58.50 = 188.50 off

Amount left

1,105

1,111.50

10% then 10% on 1,000

200 off

190 off

The setting is in the quote service, under Pricing, as Discount stacking: Parallel, amounts add or Sequential, on the remainder. The hint beside it reads "Parallel 10%+10%=20% ยท Sequential=19%". A fee marked Discountable is also reduced by a whole-quote discount, see Taxes and fees.

3. Fees before tax

A fee is an extra charge. A fixed fee adds its amount. A percentage fee takes its percentage of a base that you choose when you create the fee:

  • Net, after discounts: what is left after all discounts.

  • Subtotal, after line discounts: the subtotal before whole-quote discounts.

  • Gross, before discounts: the lines at full price.

A taxable fee joins the amount tax is worked out on. A fee that is not taxable adds to the total but is never taxed.

4. Tax

Tax is worked out on the amount after discounts, plus any taxable fees. An exclusive tax is added on top. An inclusive tax is already inside the price: Commerce shows how much of the price is tax but adds nothing. A compound tax is worked out on the amount plus the other taxes (tax on tax).

Example: base 1,145 with 10% exclusive tax adds 114.50. The same base with 10% inclusive tax adds nothing, and the tax inside it is 1,145 / 1.10 x 0.10 = 104.09.

Fees and taxes you add to a single line are worked out on that line only and added to the totals. They never change the base of the whole-quote fees and taxes, so nothing is taxed twice.

5. Surcharges after tax

A surcharge is a fee set to Surcharge, after tax, such as a card payment charge. It is worked out last. What it is worked out on is the Surcharge base setting in the quote service, under Pricing:

  • Payable total (incl. tax), the default: the amount the customer would pay before the surcharge, with tax.

  • Net amount (pre-tax): only the amount after discounts, before fees and tax.

A surcharge is never taxed and never discounted. Several surcharges do not charge each other.

6. Rounding

Money has whole cents (or the whole unit of your currency). The Tax & fee rounding setting, in the same Pricing section, decides where amounts are rounded:

  • Per document, round totals once (default): Commerce adds the exact amounts and rounds the tax and the fees once at the end.

  • Per line, round each, then sum: each line's tax and fees are rounded first, then added up.

The two can differ by a cent. Example: three lines of 10.05 each, with 5% tax.

Per document

Per line

Tax on each line, exact

0.5025

0.5025

Tax on each line, shown

0.50

0.50

Total tax

30.15 x 5% = 1.5075, rounded once: 1.51

0.50 + 0.50 + 0.50 = 1.50

Total

31.66

31.65

With Per document, the one-cent gap between the three displayed 0.50 and the 1.51 total shows as a separate Rounding row of 0.01 in the totals. With Per line there is never a Rounding row. Rounding goes half up: 0.5 rounds up to the next cent.

Discounts are always rounded to whole cents too, and never to more than the amount that is left to discount.

A fully worked example

Northwind Analytics quotes two lines.

  • Line 1: 10 seats. List price 100. A price rule gives 90 per unit from 10 units.

  • Line 2: 1 onboarding workshop at 500, with a 20% line discount.

The quote also carries:

  • Two whole-quote discounts: "Spring promo" 10% and "Loyalty" 5%.

  • A fee, "Handling", fixed at 40, before tax, taxable.

  • A tax, "VAT", 10%, exclusive.

  • A surcharge, "Card payment", 3%, after tax.

The service uses the defaults: Parallel stacking, Payable total (incl. tax) as the surcharge base.

Step

Calculation

Result

Line 1

10 x 90 (price rule applied)

900

Line 2

1 x 500 = 500, less 20% (100)

400

Subtotal

900 + 400

1,300

Discount "Spring promo"

10% of 1,300

-130

Discount "Loyalty"

5% of 1,300 (Parallel: the same base)

-65

After discounts

1,300 - 195

1,105

Fee "Handling"

fixed

+40

Taxable base

1,105 + 40 (the fee is taxable)

1,145

Tax "VAT"

10% of 1,145

+114.50

Before surcharge

1,105 + 40 + 114.50

1,259.50

Surcharge "Card payment"

3% of 1,259.50 = 37.785, rounded half up

+37.79

Total

1,259.50 + 37.79

1,297.29

The totals block under the lines of a quote

Now change one setting at a time and see what moves:

Change

New total

Why

Discount stacking to Sequential

1,304.65

The discounts total 188.50, so 1,111.50 remain. Taxable base 1,151.50, tax 115.15, before surcharge 1,266.65, surcharge 38.00

Surcharge base to Net amount (pre-tax)

1,292.65

The surcharge is 3% of 1,105 = 33.15, so 1,259.50 + 33.15

"Handling" made not taxable

1,293.17

Taxable base 1,105, tax 110.50, before surcharge 1,255.50, surcharge 3% = 37.665 rounded to 37.67

Troubleshooting

Problem

Why it happens

What to do

The total is a cent off my calculator

Rounding: per document and per line differ

Check Tax & fee rounding in the quote service, Pricing

Two discounts take less than their sum

Discount stacking is Sequential

Change it to Parallel, or expect 19% for 10% + 10%

The surcharge is bigger than I expected

The base is Payable total (incl. tax)

Switch the Surcharge base, or lower the percentage

Tax is charged on a fee

The fee is Taxable

Untick Taxable on the fee

A discount does not reduce a fee

The fee is not Discountable

Tick it on the fee, see Taxes and fees

The unit price is lower than the list price

A price rule applied

Open the line and read the rule, see Price rules

An order or invoice shows a different total than its quote

The order and the invoice are priced by their own service, and only quote services have a Pricing section, so they use the standard choices (Per document, Payable total (incl. tax), Parallel)

Keep your quote service on those choices, or check the lines