Martijn Hoogeveen
01 Software · SW-06

Margin-Safe Pricing Engine

Prices 200+ parts and kits from landed cost (supplier price, exchange rate, freight modelled from real sea and air quotes, finish uplifts) and refuses to publish anything that fails its margin and stress tests.

Ticket
SW-06
Type
Internal tool · Finance
Status
In use
Owner
Martijn Hoogeveen
Started
Nov 2026

01Problem statement

More than 200 parts, five finishes each, plus kits, all priced by hand over time. Real cost depends on the supplier's price, the exchange rate, how the part ships (a canard by air costs nothing like a bumper by sea) and the finish. A review showed prices had drifted away from cost, and many single-part orders were unprofitable once freight and FX were counted.

02Goals

In scope

  • Price every part and kit from cost
  • All assumptions in one config
  • Impossible to apply a bad change

Out of scope

  • Dynamic or competitor-based pricing

03Acceptance criteria

  • Every part, kit and real past order keeps ≥ 25% margin
  • Still profitable at worse FX and freight × 1.25
  • Report-only by default
  • Apply asks for confirmation and backs up first
  • Finish uplifts preserved

04Design

  • config.toml holds FX, uplifts, fees and real freight quotes
  • Freight is fitted as fixed + per-unit cost from sea and air quotes
  • Parts and kits are priced, then tested
  • Output is a CSV report, or a guarded apply
passfailconfig.tomlfx · uplifts · feesFreight quotessea · airFitfixed + per unitModelparts · kitsTests≥25% · stressApplybackup firstReportdefault--apply is blocked unless every test passes
Fig. 1 · System architecture
Scope
200+ parts and every kit, five finishes each
Inputs
Supplier cost, FX, freight quotes, finish uplifts, checkout fees
Freight model
Fixed + per-unit fit from real sea and air quotes
Kits
Priced from their parts, with a bundle discount
Tests
Every part, kit and real past order ≥ 25% margin
Stress
Still profitable at worse FX and freight × 1.25
Safety
Report-only by default; apply blocked unless tests pass, backup first

05Key decisions

DecisionAlternative consideredWhy
Tests as a hard gate on applyA warning in the reportA bad price is expensive; the tool should refuse
Two shipping groupsMany size classesSimpler to reason about, with nearly the same accuracy
Worked examples agreed before any writeApply, then reviewPricing is a business decision, not just a calculation

06Failure modes

RiskMitigation
Store automation re-derives finish pricesIts multipliers must match the model, or it overwrites them
An interim change goes out before agreementRestored from backup the same day; nothing writes without agreed examples now

07Testing & rollout

Testing

  • Built-in margin and stress tests
  • Every real past order replayed through the model

Rollout

  • Report shared, examples agreed, then applied with backups

08Outcome

  • Parts and kits repriced from cost on 13 November 2026

09Follow-ups

  • Align the store automation's finish multipliers with the model

Labels

  • Python
  • TOML config
  • Shopify Admin GraphQL
  • Unit economics
  • Cost modelling
  • Stress testing
  • Config-driven
  • Safe deploys