Context
Welkin & Meraki ran their entire commercial model on Salesforce: opportunities, contracts, contract line items, orders, order line items. Each year the rental amount needed to be revalued for inflation (indexation, typically 3%). Some contracts were VAT-free; some products required a deposit; renewals had to inherit fields from the parent contract correctly. The codebase had grown organically. Eight separate places assigned price to an OrderLineItem, and indexation was being applied twice on renewal contracts, inflating prices the moment a deal converted from opportunity.
Our role
Refactor delivery on the contract and order subsystem: the four classes that together decided what a renewal actually cost.
What we delivered
- Indexation rebuild. Introduced an explicit indexation flag on each line so indexation became a traceable property, not an implicit recalculation that fired in five places. Renewals now apply indexation exactly once.
- VAT-free contract path. New explicit VAT-free flag on Opportunity, threaded through the contract and order conversion paths so VAT exemption survived all the way to order generation. Total Contract Value calculation was untangled from VAT inclusion.
- Deposit logic. Deposit checks moved into the order-creation step, driven by product configuration, so deposits stopped being silently dropped during contract conversion.
- Credits policy. New rule (zero credits on contracts starting after a cutover date, except where the parent contract pre-dated the cutover) implemented as a single readable conditional in the contract trigger.
- Renewal Contract logic stabilised. The doubled-indexation bug fixed at the source rather than papered over with subtraction logic.
The biggest win was making the contract math legible. Eight assignment paths became one named flag, one boolean, one source of truth.
Outcome
Renewals stopped surprising the sales team. Contract amounts on the renewed opportunity matched what the salesperson expected to quote, instead of carrying a hidden 3% bump that had to be undone manually. The VAT-free path made tax-exempt deals possible without engineering escalation. Most importantly, the contract subsystem became something the next developer could read: explicit flags on objects, named indexation rules, a single conversion path. The pricing logic we built remains in production today.