Welcome to the billing utilities team. This module computes a transaction fee by tier, with a minimum fee floor. tiers.rate_for picks the rate for an amount and tiers.MIN_FEE_CENTS holds the floor; fees.fee_for computes…
Welcome to the billing utilities team. This module computes a transaction fee by tier, with a minimum fee floor. tiers.rate_for picks the rate for an amount and tiers.MIN_FEE_CENTS holds the floor; fees.fee_for computes the fee. Money is integer cents.
There is one ticket below. Fix as much of it as you can in 35 minutes. It is graded by several separate checks, so fixing one part (the tier boundaries or the minimum fee) still counts even if the other is not done.
Fees are wrong at the tier edges and for small amounts. The tier comparisons use <=, so a boundary amount falls into the higher-rate tier, and there is no minimum-fee floor, so small transactions are charged less than the agreed minimum.
fee_for(10000) is 100 (the boundary is in the 1% tier) and fee_for(100000) is 500.fee_for(2000) is 50 (the floor, since 2% is 40).Keep the public function fee_for.
tiers.py (rate_for and MIN_FEE_CENTS) and fees.py (fee_for). The shipped regression tests are in tests/visible/; every one of them fails until the bugs are fixed.pytest tests/visible.Adapted from treasure567/bloomberg-practice (round-1/quasar @ 8de07d5), used with the author's permission.
Visible test command
pytest tests/visibleThe repository’s own tests. Run all tests includes them, and so does every submission.
Repository
transaction-fee-tiers-and-minimum-fee
Changes under src/ are evaluated.