"5% up to $50,000, 8% above it" looks like one rule. In code it is two different functions, and the gap between them on $70,000 of sales is $1,500.
from decimal import Decimal as D
TIERS = [(D("50000"), D("0.05")), (None, D("0.08"))]
def marginal(base):
total, floor = D("0"), D("0")
for cap, rate in TIERS:
top = base if cap is None else min(base, cap)
if top > floor:
total += (top - floor) * rate
if cap is None or base <= cap:
break
floor = cap
return total
def retroactive(base):
for cap, rate in TIERS:
if cap is None or base <= cap:
return base * rate
print(marginal(D("70000")), retroactive(D("70000"))) # 4100.00 5600.00
The plan document has to say which one it means. If it does not, the software should ask rather than default.
Returns after the period is paid
A $5,000 return arrives after the period was approved and paid. Recalculating the closed period in place would silently change a statement the seller already received. Instead, compute the difference and post it as a correction in the next open period:
paid = marginal(D("70000")) # 4100.00, frozen with the approved period
should_be = marginal(D("65000")) # 3700.00
correction = should_be - paid # -400.00 -> next open period, linked to the sale
print(correction)
Two rules keep this honest:
- Approved periods are immutable. Corrections are new lines that point to the original sale and plan version.
- Negative balances are not deducted automatically. Whether a clawback can be taken from pay is a policy and legal question, not arithmetic.
Split deals add one more check: shares must total exactly 100%, and you must decide whether tiers apply to the whole deal or to each seller's own base for the period.
This is the model behind Sales Commission & Payout Control (PAID $19 one-time, free demo).
Top comments (0)