from .models import Coupon

def discount_amount(subtotal: float, coupon: Coupon | None) -> float:
    if coupon is None or subtotal < coupon.min_subtotal:
        return 0.0
    return round(subtotal * coupon.percent, 2)
