"""Fictional EUR case; no statutory tax or supplier-price calculation."""
def funding(cash, cleared_topup, gross=300, employer_cost=35, run_fee=0):
    required = gross + employer_cost + run_fee
    return {"required": required, "available": cash + cleared_topup, "balance": cash + cleared_topup - required, "fundable": cash + cleared_topup >= required}
def invoice_due(invoice, applied_credit):
    return invoice - applied_credit
if __name__ == "__main__":
    assert funding(250,0)["balance"] == -85
    assert funding(250,100)["balance"] == 15
    assert funding(250,80)["balance"] == -5
    assert funding(250,100,run_fee=50)["balance"] == -35
    assert 210 + 90 + 35 == 335
    assert invoice_due(9000,0) == 9000
    assert invoice_due(9000,120) == 8880
    print("7 assertions passed: funding, shortage, fee sensitivity, pay split, applied credit")
