2026-08-05 19:03:04 -03:00
|
|
|
"""Order pricing helpers for the Hermes code-repair demo."""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def apply_discount(subtotal: float, percent: float) -> float:
|
|
|
|
|
"""Return the subtotal reduced by a whole-number discount percent.
|
|
|
|
|
|
|
|
|
|
Inputs: the order subtotal and a discount percent between 0 and 100.
|
|
|
|
|
Outputs: the discounted total, rounded to two decimal places.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
if percent < 0 or percent > 100:
|
|
|
|
|
raise ValueError("percent must be between 0 and 100")
|
2026-08-07 13:48:17 +00:00
|
|
|
return round(subtotal * (1 - percent / 100), 2)
|