How HubSpot calculates and round line item net pricing when discounted by percentage?
HubSpot users sometimes ask how a discount percentage is calculated and applied to a line item.
Is the discount applied to the individual item price and then multiplied by quantity? Or is it applied to the total line item price? When the quantity is greater than 1, the answer may differ due to rounding.
The short answer is that HubSpot applies the percentage discount to the total line item price, not the individual product price.
Example: A line item of 10 products at $234.56 each, with a 20% discount applied.
If HubSpot applied the discount to the individual item price:
- Item price $234.56 × 20% discount = $187.648, rounded to $187.65
- 10 items × $187.65 = $1,876.50
What HubSpot actually calculates:
- Total line item price = $234.56 × 10 = $2,345.60
- Total line item discount = $2,345.60 × 20% = $469.12
- Net line item price = $2,345.60 − $469.12 = $1,876.48
The difference is $0.02.
Often this small discrepancy is not a problem. However, if your customer contract states a discounted price per item, the actual price the customer pays may differ slightly when ordered in quantity.
Solutions to line item discount % rounding errors
If this is a problem for your organisation, here are a couple of solutions:
- Convert the discount % to a fixed amount per line item. This can be problematic because the sales rep must calculate the total discount and enter it as a fixed amount, then adjust it if the quantity changes.
- A better solution is to use DoPricer CPQ to apply a custom price list for the customer, with a distinct per-item price stated per product SKU. A custom price list ensures that regardless of quantity, DoPricer will always apply the customer's contracted per-item price.
Technical Details
For those interested in the technical detail, here are the three HubSpot line item calculation properties that apply a discount % to the line item total.
hs_pre_discount_amount
round_nearest((if is_present(price) then price else 0 * if is_present(quantity) then quantity else 1), if is_present(string(hs_line_item_currency_code)) then if is_present(currency_decimal_places(string(hs_line_item_currency_code))) then currency_decimal_places(string(hs_line_item_currency_code)) else 3 else 3)
Simplified: price × quantity
hs_total_discount
round_nearest(if is_present(discount) then (discount * if is_present(quantity) then quantity else 1)
elseif is_present(hs_discount_percentage) then (hs_discount_percentage * 0.01 * if is_present(hs_pre_discount_amount) then hs_pre_discount_amount else 0) else 0, if is_present(string(hs_line_item_currency_code)) then if is_present(currency_decimal_places(string(hs_line_item_currency_code))) then currency_decimal_places(string(hs_line_item_currency_code)) else 3 else 3)
Simplified to either:
discount × quantity(if the line item uses a fixed discount value)hs_discount_percentage × 0.01 × hs_pre_discount_amount(if the discount is a percentage)
amount
round_nearest(if is_present(hs_sync_amount) then hs_sync_amount else (if is_present(hs_pre_discount_amount) then hs_pre_discount_amount else 0 - if is_present(hs_total_discount) then hs_total_discount else 0), if is_present(string(hs_line_item_currency_code)) then if is_present(currency_decimal_places(string(hs_line_item_currency_code))) then currency_decimal_places(string(hs_line_item_currency_code)) else 3 else 3)
Simplified: hs_pre_discount_amount − hs_total_discount
Note: hs_sync_amount is set by the Ecommerce sync and overrides line item calculations, accepting the synced price directly.
Summary
When the discount is a percentage, HubSpot:
- Calculates the total line item price before discounts (
hs_pre_discount_amount) - Calculates the total discount by applying the discount percentage to the total line item price, rounded to the appropriate decimal places for the currency (
hs_total_discount) - Subtracts the total discount from the total line item price to arrive at the net line item price (
amount)