A profitable order can still push a business under its cash reserve: costs leave on day one, the customer pays on day 60, and the rest of the business keeps spending in between. Two numbers fix it, and both have a closed form: the smallest deposit and the longest payment terms that keep the lowest cash at or above the reserve.
Here it is with fractions.Fraction so the daily burn (a monthly figure divided by 365/12 days) stays exact until the final rounding.
from fractions import Fraction as F
import math
def deal(order, costs, dep_pct, days, cash, reserve, monthly_net, rate_pct):
"""Amounts in integer cents, monthly_net signed (negative = business uses cash)."""
daily = F(monthly_net) / (F(365) / 12) # exact, no floats
deposit = order * dep_pct // 100
low = cash + deposit - costs + daily * days # just before the balance arrives
# smallest whole-percent deposit that keeps low >= reserve
need = reserve - (cash - costs + daily * days)
min_dep_pct = math.ceil(need * 100 / order) if need > 0 else 0
# longest whole number of days before cash crosses the reserve (daily < 0)
max_days = math.floor((cash + deposit - costs - reserve) / -daily) if daily < 0 else None
carry = F(costs - deposit) * rate_pct / 100 * days / 365
profit = order - costs - carry
return low, min_dep_pct, max_days, profit
low, dep, days, profit = deal(4_800_000, 3_000_000, 20, 60, 3_800_000, 1_500_000, -150_000, 12)
print(round(low) / 100, dep, days, round(profit) / 100)
Output:
14641.1 21 52 17597.59
The example: a $48,000 order, $30,000 of costs paid up front, a 20% deposit, 60-day terms, $38,000 in the bank, a $15,000 reserve and the rest of the business using $1,500 a month. Just before the balance arrives cash sits at $14,641.10, so the order breaks the reserve by about $359.
Rounding is where these tools usually go wrong, so the directions are deliberate:
-
Deposit rounds up (
math.ceil). 20.75% is the exact minimum; 21% keeps you safe, 20% does not. -
Days round down (
math.floor). 52.7 days means day 52 is the last safe day. -
Keep the daily burn as a fraction.
150000 / (365/12)in floats is fine once, but repeated over days and scenarios the drift shows up in the cents. - Carry cost on the cash you are out of pocket, not on the whole order: ($30,000 − $9,600) × 12% × 60/365 ≈ $402, so the order is worth about $17,598 after waiting.
If you would rather not run code, the same arithmetic is in a free browser tool: Deal Safety Calculator (free, no sign-up).
Top comments (0)