Commission on the Tax — JavaScript Bug Hunt
Modelled on Uber's New York City driver underpayment (acknowledged May 2017): since late 2014 Uber had been calculating its commission on NYC drivers' gross…
- Language: JavaScript
- Layer: Backend
- Difficulty: Easy
- Concepts: Money, Validation
- Modelled on: Uber · 2017
- Visible tests: a trip with no tax or fees; commission is taken from the fare, not the taxes
- Reward: 50 XP for a complete fix
Briefing
Modelled on Uber's New York City driver underpayment (acknowledged May 2017): since late 2014 Uber had been calculating its commission on NYC drivers' gross fares, including sales tax and Black Car Fund fees, instead of on the fare after those pass-through charges. Uber said it would repay the affected drivers with interest — reported at tens of millions of dollars.
statement.js is a reconstruction of the per-trip driver statement. Taxes and fees are collected from the rider and passed on; they are not part of the fare the commission applies to.
Fix statement so the commission is taken from the fare alone.
Bug report
BUG-NYC-COMM · Priority: High (driver pay) · Reported by: driver support
statement(trip) — all amounts in integer cents — returns, in this key order:
- gross: trip.fare + trip.salesTax + trip.blackCarFund (what the rider paid)
- commission: Math.round(trip.fare * rates.COMMISSION_RATE) (the fare only — never tax or fees)
- taxesAndFees: trip.salesTax + trip.blackCarFund
- driverPay: trip.fare - commission
Example: fare 2000, tax 177, BCF 50 -> { gross: 2227, commission: 500, taxesAndFees: 227, driverPay: 1500 }
Observed: commission 557 and driver pay 1443 on that trip.
Logs
[payouts] trip=nyc-88213 fare=2000 tax=177 bcf=50 commission=557
[payouts] weekly statement NYC: commission base includes tax + BCFThe code as shipped
src/pay/statement.js (editable)
var rates = require("./rates");
// Per-trip driver statement. All amounts are integer cents.
exports.statement = function (trip) {
var gross = trip.fare + trip.salesTax + trip.blackCarFund;
var taxesAndFees = trip.salesTax + trip.blackCarFund;
var commission = Math.round(gross * rates.COMMISSION_RATE);
return {
gross: gross,
commission: commission,
taxesAndFees: taxesAndFees,
driverPay: gross - taxesAndFees - commission
};
};
Read-only context: src/pay/rates.js.
Open the hunt to edit the files, run the visible tests and submit against the hidden ones. More JavaScript bug hunts.