A fixed-price contract has two numbers: what the customer pays and what the developer retains. Confusing them creates a budget error before a single line of application code is written.
This tutorial builds a small, testable pricing model in Python. It uses integer cents, explicitly models a minimum service fee, and turns a target net amount into the smallest conservative quote. All amounts and fee rates below are illustrative, not recommendations or promises about any marketplace.
1. Start with the work, not the marketplace
Imagine a developer quoting a small dashboard integration:
| Work package | Hours |
|---|---|
| Discovery and acceptance criteria | 3 |
| API integration | 9 |
| UI and error handling | 8 |
| Tests and deployment | 5 |
| Delivery and handover | 3 |
| Total | 28 |
At an internal target of $40 per hour, the developer wants $1,120 after the modeled service fee. Add a separately budgeted $80 for scope uncertainty and the target becomes $1,200.
The $80 is not a replacement for a change-control clause. It is a planning allowance for uncertainty within the defined scope. Taxes, currency conversion, payout charges, hosting expenses and other overhead are outside this simplified example; include them separately if applicable.
Now assume a service fee of 12%. Quoting $1,200 to the customer would leave only $1,056. Adding 12% to the target gives $1,344, which leaves $1,182.72: still $17.28 short.
Instead, divide the target by the retained fraction:
gross = 1200 / (1 - 0.12)
= 1363.636363...
Round the gross upward to $1,363.64. The extra precision matters because the goal is a minimum, not an average.
2. Define the fee contract explicitly
A useful estimator separates the accounting policy from the user interface. In this example:
- Money is represented as integer cents.
- Percentages are represented in basis points: 1,200 means 12%.
- The percentage fee is rounded upward to the next cent as a conservative assumption.
- The fee is the larger of that percentage fee and a specified minimum.
- The rate must be less than 100%.
Actual marketplaces may round differently or charge fees in more complicated ways. This is an intentional, reproducible model, not a claim that every payment processor uses the same accounting rules.
Let the gross price be G, the target net be N, the fee fraction be r and the minimum fee be m. The requirements are:
G - r * G >= N
G - m >= N
Both must be true. Therefore the gross price must be at least the larger of N / (1 - r) and N + m. With integer cents we can compute that boundary without using binary floating point.
3. Implement the calculator
from dataclasses import dataclass
BPS = 10_000
def ceil_div(n: int, d: int) -> int:
return (n + d - 1) // d
@dataclass(frozen=True)
class FeeModel:
rate_bps: int
minimum_cents: int = 0
def __post_init__(self):
if not 0 <= self.rate_bps < BPS:
raise ValueError("rate must be in [0, 10000)")
if self.minimum_cents < 0:
raise ValueError("minimum fee must be nonnegative")
def fee(self, gross_cents: int) -> int:
if gross_cents < 0:
raise ValueError("gross must be nonnegative")
return max(
self.minimum_cents,
ceil_div(gross_cents * self.rate_bps, BPS),
)
def net(self, gross_cents: int) -> int:
return gross_cents - self.fee(gross_cents)
def quote(self, target_cents: int) -> int:
if target_cents < 0:
raise ValueError("target must be nonnegative")
return max(
ceil_div(target_cents * BPS, BPS - self.rate_bps),
target_cents + self.minimum_cents,
)
Why does the inverse work even when the fee rounds upward? Because the target and gross are integers. For integer G and N, the requirement ceil(G*r) <= G-N is equivalent to G*r <= G-N. The ceiling does not invalidate the inequality. We can then solve it using integer division and take the larger of the two fee constraints.
For the dashboard example:
model = FeeModel(1200)
assert model.quote(120_000) == 136_364
assert model.net(136_364) == 120_000
assert model.net(136_363) == 119_999
The last assertion is important. It verifies that the quote is not just sufficient; it is the smallest sufficient integer-cent amount under this policy.
4. Test the fee-floor boundary
Consider a separate hypothetical marketplace with a 10% fee or a $5 minimum. A small $10 net target requires a $15 quote, not $11.12, because the minimum fee dominates.
floor_model = FeeModel(1000, 500)
assert floor_model.quote(1000) == 1500
assert floor_model.net(1500) == 1000
assert floor_model.quote(10_000) == 11_112
Include a boundary test over several rates and targets rather than trusting a couple of happy-path examples:
for rate in (0, 1000, 1200, 2000, 9999):
for minimum in (0, 500):
model = FeeModel(rate, minimum)
for target in (0, 1, 499, 1000, 120_000):
gross = model.quote(target)
assert model.net(gross) >= target
if gross > 0:
assert model.net(gross - 1) < target
A very high rate produces a very high quote. That is mathematically consistent, but a real pricing interface should warn the user when the result is commercially impractical.
5. Model scope changes independently
Suppose the customer requests an additional export workflow estimated at four hours. At $40 per hour, the new target is $160. With the illustrative 12% fee, the incremental quote, if treated as its own transaction without a minimum fee, is $181.82.
If the work is added to the original contract and fees apply on the combined amount, compute the difference between the revised total quote and the original quote instead:
model = FeeModel(1200)
original = model.quote(120_000)
revised = model.quote(136_000)
increment = revised - original
assert revised == 154_546
assert increment == 18_182
These approaches may differ when a fixed minimum fee is applied separately to each invoice. Before automating invoicing, determine whether the fee applies per project, per milestone, or per transaction. Do not silently assume that dividing a contract into milestones leaves every fee unchanged.
Document the change in writing: the new deliverable, its acceptance test, the additional charge, the revised delivery date, and any dependency on the customer's data.
6. Turn the estimate into a quote review
Before sending the proposal, record the internal target, the service-fee assumption, the gross quote, excluded costs and the rounding policy. Recalculate if the contract terms change. The customer-facing quote should describe the deliverables, milestones and total price; the internal calculations are for checking the sustainability of the work.
For a quick manual comparison of modeled service fees and reverse-price estimates, Freelance Fee Calculator provides a web interface. Disclosure: this article is published by NexaByte to demonstrate the concepts behind a tool we promote. The independent Python examples above are sufficient to reproduce the calculations without using the site. Check your actual platform contract before relying on any estimated fee.
A reliable pricing tool is not a substitute for negotiating scope. Its value is that you can explain every cent, rerun the calculations when assumptions change, and test the result before sending a quote.
Top comments (0)