
From: Priya Nair (City Operations) To: You Subject: Pricing is in a spreadsheet. Help.
Finance found three pricing mistakes this month — all from the fee spreadsheet people keep editing by hand. I want the whole thing as code: one function per rule, each one tested, composed into a single engine.
The rules are below, one step at a time. Build each function, run the
checks, and don't move on until the step is green. By the end, orderTotal
and riderPayout will be the only two functions anyone at Zesto needs.
One thing I care about a lot: later functions must CALL the earlier ones — if I see the base-fare bands re-typed inside the surge logic, we're back to three copies of the truth, which is how the spreadsheet died.
You'll practice
First rule, straight from the rate card: a delivery up to 2 km costs a flat 25. Beyond that it's 25 + 9 per full km past 2 (partial km don't count — 4.5 km bills like 4 km).
Write baseFare(km).