Skip to content

No. 71Backend8 min read2,175 words

How to build a B2B quoting tool (CPQ): a practical guide

How to build a B2B quoting tool sales teams trust: pricing rules, discount approvals, price snapshots, PDF quotes, the stack we use and what drives cost.

Written by
Lazy Devs
Published
Updated
Sources
Cited inline

Key takeaways · 05

The short version

  1. 01A B2B quoting tool MVP needs a product catalogue, a quote builder with live totals, a discount engine with limits, an approval step, branded PDFs and a shareable accept link.
  2. 02Snapshot prices and descriptions onto each quote line when it is created. Quotes that read live catalogue prices get silently rewritten when prices change.
  3. 03Evaluate pricing rules in a fixed, documented order and store a trace of each adjustment, so anyone can see why a price came out the way it did.
  4. 04Store money as integer minor units or an exact decimal type, never floating point, and pick one rounding rule used everywhere, because Postgres and JavaScript round ties differently.
  5. 05Discount ceilings with approval routing and an audit trail are usually the reason companies build a quoting tool in the first place. Build them into the first release.
On this page · 11

To build a B2B quoting tool, start with a product catalogue, a quote builder with live totals, a discount engine with hard limits, an approval step for big discounts, branded PDF output and a link the customer can accept. Then get three details right from day one: snapshot prices onto each quote, evaluate pricing rules in a fixed order, and keep an audit trail of every approval.

Most B2B sales still run on a spreadsheet that one person guards with their life. Someone mistypes a discount, the margin quietly disappears, and nobody notices until finance asks why the deal lost money. A quoting tool fixes that by turning pricing from tribal knowledge into something the whole team can use without breaking it.

What a B2B quoting tool is, and who needs one

A B2B quoting tool, often called CPQ (configure, price, quote), lets a salesperson build an accurate, branded quote in minutes instead of hours. It takes products, quantities and discounts, applies your real pricing rules and produces a document the customer can accept.

It is for companies whose pricing is not a fixed price tag: tiered subscriptions, volume breaks, customer-specific price lists, configurable products, or anything that needs sign-off above a certain discount. Manufacturers, distributors, B2B SaaS and professional services firms are the usual audience. Contractors who price jobs from site visits have a close cousin of the problem, covered in field service and construction software. If your pricing fits on a menu, you do not need this yet.

The one job it must do well: produce a quote that is correct. Correct price, discount, totals and terms. A good-looking quote with the wrong total is worse than no tool, because people will trust it.

Build or buy?

SituationBetter choice
Standard pricing, already on a major CRM with a CPQ add-onBuy the add-on
A handful of products, rare discountsA spreadsheet template or your invoicing tool's quotes
Complex rules, customer-specific price lists, multi-step approvalsCustom tool
Configurable products tied to production, inventory or an ERPCustom tool
Quotes need to turn into subscriptions automaticallyEither; check whether your billing provider's quotes feature, such as Stripe Quotes, covers it first

The quoting tool MVP feature set

Resist modelling every pricing edge case on day one. Ship the spine first. The bar for the MVP is simple: one sales team can retire its spreadsheet.

Build first

  • A product and price catalogue. SKUs, list prices, units and active dates.
  • A quote builder. Add line items, set quantities, see live totals.
  • A discount engine with guardrails. Percentage or fixed, with a maximum each role can apply alone.
  • An approval step when a discount crosses a threshold.
  • Branded PDF generation.
  • A shareable quote link with accept and decline.
  • Roles. Rep, manager, admin.

Build later

  • CRM sync, so quotes attach to deals automatically.
  • E-signature and contract terms.
  • Multi-currency and tax logic.
  • Quote versioning, renewals and amendments.
  • Bundles, dependencies and configurable products.
  • Analytics on win rates and discount leakage.

If you are still working out the sales process itself, keep the catalogue small and treat this like any other MVP for a startup.

Pricing rules are a domain, not a form

This is where quoting tools eat budgets. "Apply a discount" sounds simple until several rules hit the same line: a customer-tier discount, a volume break, a promotion and a manager exception. Which wins? Do they stack? Does a percentage apply to the list price or to the already-discounted price?

You need three things:

  1. A fixed evaluation order, written down and agreed with sales and finance. For example: list price, then customer price list, then volume break, then promotion, then manual discount.
  2. An explicit stacking policy for each rule type: does it compound, add up or replace earlier discounts?
  3. A trace of every adjustment, shown to the rep and stored with the quote, so anyone can see why a price came out the way it did.

Keep the pricing engine in plain, well-tested functions, not buried in database triggers or UI components. A simplified example in TypeScript, working in integer cents:

type Line = { unitPriceCents: number; quantity: number };
type Rule = { kind: "priceList" | "volume" | "promo" | "manual"; pct: number; reason: string };
 
// Rules apply in a fixed order, each to the result of the previous step (compounding).
const ORDER: Rule["kind"][] = ["priceList", "volume", "promo", "manual"];
 
export function priceLine(line: Line, rules: Rule[]) {
  let cents = line.unitPriceCents * line.quantity;
  const trace = [{ step: "List price", cents }];
 
  for (const kind of ORDER) {
    for (const rule of rules.filter((r) => r.kind === kind)) {
      const discount = Math.round((cents * rule.pct) / 100);
      cents -= discount;
      trace.push({ step: rule.reason, cents: -discount });
    }
  }
  return { totalCents: cents, trace };
}

This kind of function is easy to unit test with real examples from your sales team, which is exactly where most of your test effort should go. Our post on a testing strategy that pays off explains why logic like this deserves dense tests while UI gets lighter coverage.

Rounding will start arguments

A percentage off a unit price, multiplied by quantity, can differ by a cent from the same percentage off the line total. Finance will notice. Decide once whether you round per unit, per line or per quote, and apply it everywhere.

Watch for rounding differences between layers, too. Postgres's numeric type rounds ties away from zero, while JavaScript's Math.round rounds ties toward positive infinity, so the two disagree on negative values like credits. Calculate in one place and store the result, rather than recalculating in the database and the browser. Display amounts with Intl.NumberFormat, never by hand-formatting strings.

Quotes must be immutable once sent

If a customer accepts a quote, the numbers they saw are the numbers you are bound to. Your catalogue keeps changing, so a quote cannot reference live prices. It has to snapshot them. This is the mistake teams regret most: quotes that read from the current catalogue, until a price change silently rewrites quotes that were already sent.

Snapshot the price and description onto the line item when it is added, and freeze the whole quote when it is sent:

create table quotes (
  id            uuid primary key default gen_random_uuid(),
  number        text unique not null,           -- human-facing, e.g. Q-2026-0142
  version       integer not null default 1,
  account_id    uuid not null references accounts(id),
  owner_id      uuid not null references users(id),
  status        text not null default 'draft',  -- draft | pending_approval | sent | accepted | declined | expired
  currency      char(3) not null default 'USD',
  valid_until   date,
  sent_at       timestamptz,
  created_at    timestamptz not null default now()
);
 
create table quote_line_items (
  id                uuid primary key default gen_random_uuid(),
  quote_id          uuid not null references quotes(id) on delete cascade,
  product_id        uuid not null references products(id),
  description       text not null,     -- snapshot, not a live join
  unit_price_cents  bigint not null,   -- snapshot of the price at the time
  quantity          integer not null check (quantity > 0),
  discount_pct      numeric(5,2) not null default 0 check (discount_pct between 0 and 100),
  line_total_cents  bigint not null,   -- computed by the pricing engine, stored at write time
  pricing_trace     jsonb not null     -- the adjustments that produced the total
);

The product table can change all it likes; the quote stays frozen. Store money as integer minor units (as here) or Postgres numeric, never as floats. To change a sent quote, create a new version rather than editing it in place, and keep the old one.

Two reps editing the same draft will happen sooner than you expect. A version column checked on every save (optimistic locking) or a row lock with select ... for update, described in the Postgres docs on explicit locking, prevents one person's changes overwriting another's.

Approvals are a workflow, not a checkbox

A discount over the threshold should route to the right approver, block the quote from being sent until they act, and record who approved what and when. When a deal goes sideways six months later, "who signed off on this discount?" is a question someone will ask.

Discount on the quoteWho can approveWhat happens
Up to the rep's limitRepQuote can be sent immediately
Above the rep's limitSales managerQuote locked in "pending approval" until decided
Above the manager's limit, or below a margin floorFinance or leadershipSecond approval step
Non-standard termsLegal or financeSeparate approval regardless of discount

The exact thresholds are a business decision. The engineering requirements are the same either way: approvals tied to a specific quote version, notifications to approvers, a clear history and no way to bypass the gate. Margin floors are often a better rule than discount percentages, because they protect profit even when list prices change.

PDFs, acceptance and e-signatures

The PDF is what the customer forwards to their finance team, so it must match the screen exactly.

  • Render on the server from the same quote data, using a headless browser (Playwright can print pages to PDF) or a component library like React-PDF.
  • Store the generated PDF with the quote version, and treat it as an artefact, not the source of truth.
  • Generate it in a background job, so a slow render never blocks a rep clicking "send".

For acceptance, record the accepting person's name, email, time, IP address and the exact quote version. Electronic acceptance and signatures are recognised in many places, for example under the US ESIGN Act and the EU's eIDAS regulation, but requirements vary by country and contract type. This is engineering guidance, not legal advice. For high-value contracts, integrating a dedicated e-signature provider is usually worth it.

The stack we would reach for

Nothing exotic. Quoting tools reward reliable, well-understood choices.

  • Next.js and TypeScript for the app. The quote builder is interactive, and a typed model end to end matters when a money bug is the main failure mode. This is our default for web app development.
  • Postgres for catalogue, quotes and approvals: relational, transactional, with exact numeric types and constraints.
  • A pricing engine as a plain TypeScript module, shared by the API and any preview logic, with dense unit tests.
  • Server-side PDF rendering in a background job.
  • Background jobs for emails, CRM sync and expiry reminders.

When you wire in your CRM, ERP, billing or e-signature, that is focused API and backend engineering work rather than something to front-load into the MVP. If you are building the CRM side too, our guide on how to build a custom CRM covers the data model a quoting tool usually plugs into.

What drives the cost and timeline

We do not quote a quoting tool we have not scoped. The single biggest variable is how complex your pricing rules are, and the second is integrations.

FactorSimplerMore complex
Pricing rulesFlat tiers, one discount typeCustomer price lists, volume breaks, promotions, margin floors
ProductsSimple line itemsConfigurable products with dependencies and bundles
ApprovalsOne threshold, one approverMulti-step, role and region based
Currencies and taxOne currency, tax handled elsewhereMulti-currency, tax calculation, regional terms
IntegrationsNone, or CSV exportCRM, ERP, billing and e-signature sync
DocumentsOne PDF templateMultiple templates, languages and contract terms

A vague "it depends on the deal" pricing model is the most expensive thing you can hand an engineering team. The discovery work to pin down your rules, in writing, with real example quotes, pays for itself.

Common mistakes to avoid

  • Free-text prices. Once a price field accepts anything, your catalogue stops meaning anything. Constrain prices to the catalogue and discounts to rules.
  • No discount ceiling. Without a hard cap and an approval gate, margin leaks one "just this once" at a time.
  • Live prices on saved quotes. Silent and ugly. Snapshot everything.
  • Floats for money. Use integers or exact decimals, pick a rounding rule and test it.
  • Configurable products too early. If most deals are simple line items, ship those and add configuration when a real deal demands it.
  • Skipping the audit trail. Adding it later means reconstructing history you no longer have.

Accepted quotes often become orders that customers want to track. Many teams later expose quotes, orders and invoices in a customer portal, and if you sell physical products, our post on custom software for manufacturers covers how quoting connects to production and inventory.

Where to start

  1. Collect real quotes from the last few months, including the messy ones.
  2. Write the pricing rules and their order down, and agree them with sales and finance.
  3. Build the catalogue, pricing engine and tests before the UI.
  4. Add the quote builder, approvals, PDFs and accept link.
  5. Run the tool alongside the spreadsheet for a few weeks and compare totals.

A B2B quoting tool succeeds or fails on one thing: the number is right every time, and you can prove why. That is squarely the kind of system we build, pricing logic, approvals and all. If you are sketching one out, talk to us and we will help you scope it honestly.

FAQ · 05 questions

Frequently asked questions

What is CPQ software?

CPQ stands for configure, price, quote. It is software that helps sales teams configure the products a customer needs, apply the correct pricing and discounts, and produce an accurate quote document. Off-the-shelf CPQ products are often add-ons to large CRMs, while custom quoting tools are built around one company's own pricing rules.

Should I build a custom quoting tool or buy CPQ software?

Buy if your pricing is fairly standard and you already use a CRM with a mature CPQ add-on. Build when your pricing rules, product configuration or approval process are specific enough that a packaged tool needs heavy customisation anyway, or when quoting has to connect tightly with your own systems such as an ERP or production planning.

How do I stop sales reps giving away too much discount?

Set a maximum discount each role can apply on their own, and route anything above it to an approver before the quote can be sent. Record who approved what and when, and report on discount levels by rep and product so leakage is visible rather than discovered at the end of the quarter.

Are online quote acceptances legally binding?

In many jurisdictions electronic acceptance and electronic signatures can be legally valid, under laws such as the US ESIGN Act and the EU eIDAS regulation, provided you capture clear intent and keep a reliable record. Requirements vary by country and contract type, so confirm with a lawyer what your quotes need.

How do I generate quote PDFs that match the screen?

Render the PDF on the server from the same quote data and, ideally, the same templates as the on-screen view, using a headless browser or a PDF component library. Store the generated file with the quote version so the customer's copy never changes after it is sent.

Related service

API & Backend Engineering

Secure, well-documented APIs that scale.

Learn more

Next step

Want this built right?

This is the work we do every day. Tell us what you are building and we will show you exactly how we would ship it.

First reply
Within 1 business day
Typical start
1–2 weeks
Pricing
Fixed price per phase
You own
All code and accounts