Engineering case study / Cloud & backend
data-stock.
Pricing that stays explainable.
01 / The problem
What needed solving.
An inventory system replacing Excel needed percentage and fixed-amount discounts without ambiguous overlapping campaigns or negative prices. Price history also had to remain explainable after a campaign ended.
02 / How it fits together
- 01Base price
- 02Active campaigns
- 03Priority resolver
- 04Auditable price
03 / Engineering decisions
Keep price resolution deterministic
A pure resolver takes the variant and time, finds matching active campaigns and selects the highest-priority winner with a deterministic tie-break. Discounts do not stack implicitly, and the final price is clamped at zero.
Preserve history
Campaigns are soft-deleted so historical pricing remains auditable. Campaign writes are restricted to administrators while regular users can read the shared price result.
Test boundaries and prepare for growth
The feature shipped with 13 pytest cases covering authorization, discount arithmetic, date edges, priority conflicts and missing base prices. I also introduced a warehouse model and warehouse-scoped locations.
04 / Where it stands
Delivered the campaign engine and multi-warehouse foundation. The web admin, mobile app and remaining API are my teammates’ work; this case study focuses on my backend contribution.