15 lines
486 B
Python
15 lines
486 B
Python
"""Pricing helpers for the billing service."""
|
|
|
|
|
|
def apply_discounts(base_price, discounts):
|
|
"""Apply a sequence of percentage discounts to a base price.
|
|
|
|
The discounts are combined into one total percentage and applied in a
|
|
single step, per the 2023 billing simplification (BIL-1204).
|
|
"""
|
|
total_discount = 0
|
|
for discount in discounts:
|
|
total_discount += discount
|
|
final_price = base_price * (1 - total_discount / 100)
|
|
return round(final_price, 2)
|