Career

Case study · SendHub · 2022

Replacing the sales pricing spreadsheet

Sales priced deals in a large, convoluted Excel spreadsheet. I reimplemented the whole pricing model as a tested TypeScript rules engine and proved it matched the spreadsheet across a 73,750-case combinatorial test matrix. Corrections for the spreadsheet’s own defects shipped behind switches the sales team could turn on themselves.

Role
Designed and built it
When
2022
Test cases
73,750, all at parity with the spreadsheet
The pricing spreadsheet beside a test run reporting 73,750 passing tests and zero mismatches.
  • TypeScript
  • React
  • Jest
  • Yup

At a glance

Problem

The pricing rules existed only as nested formulas, branches and tiers inside a spreadsheet, and the replacement had to match it exactly.

What I did

Reverse-engineered the formulas into deterministic, validated rules in a React app, written test-first.

Result

Exact parity across 73,750 test cases, and a safe way to roll out fixes for the defects the parity tests uncovered.

The spreadsheet

The workbook held the whole pricing model: a tangle of nested formulas, conditional branches, tiered rules and thresholds. I reverse-engineered it into a structured rules engine inside a React single-page app written in TypeScript, so pricing became deterministic, testable code.

How the 73,750 test cases were built

An illustration in three cards: the sales pricing spreadsheet, a column of inputs above the prices it calculates; a table of test cases that multiplies each time one input changes; and the new pricing app, with a switch between the spreadsheet’s behaviour and the corrected rule. The five steps after it describe what happens.

  1. I start with every input at its default. I copy those inputs and the prices the spreadsheet calculates, and that’s my first test case.

  2. Then I change one input. Every case I already have gets copied with that change, and the spreadsheet gives me the new prices. A toggle doubles the cases; a dropdown with three options triples them.

  3. I do that for every input. The real spreadsheet had many more inputs than these five, which is how the suite got to 73,750 test cases.

  4. I wrote the app’s pricing logic to be correct, so some tests failed. Those failures led me to logic bugs in the spreadsheet itself.

  5. The rollout had to match the spreadsheet exactly, so by default the app reproduces those bugs and every test passes. The fixes sit behind switches the sales team could turn on themselves.

Inputs and prices are illustrative.

Key decisions

How the tests reached 73,750

I started with every input at its base value and recorded those inputs and the spreadsheet’s prices as the first case. Then I moved one input to its next option and copied every existing case with that change, recording the new prices the spreadsheet calculated for each copy. A switch doubled the cases; a three-option dropdown tripled them. Repeating that for every input took the matrix to 73,750 cases, each one checking the engine against the spreadsheet’s output.

Parity first, even with the bugs

I wrote the engine with the pricing logic as it should work. When the parity tests compared it with the spreadsheet, some of the mismatches turned out to be logic bugs in the spreadsheet itself.

The rollout required exact parity anyway, so I added a bug-compatible mode that reproduces those defects, kept the corrected logic beside it, and put runtime switches between the two. The sales team could turn the corrections on themselves, without disrupting how they worked.

Instead ofFix the defects during the reimplementation. Parity was the requirement. Changing prices during the switch would have broken it.

Validated inputs

Inputs go through strict schema validation (Yup) before the rules run, and the same inputs always give the same price, across every tier, threshold and conditional path.

SendHub's code and screens are proprietary, so the images here are redrawn. Numbers are real unless marked as illustrative.

Want to talk about this work?

Book a call, or ask my AI assistant first. It answers from my notes and shows where each answer came from.