First commit
This commit is contained in:
0
part1-pricing/pricing/__init__.py
Normal file
0
part1-pricing/pricing/__init__.py
Normal file
14
part1-pricing/pricing/discounts.py
Normal file
14
part1-pricing/pricing/discounts.py
Normal file
@ -0,0 +1,14 @@
|
||||
"""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)
|
||||
Reference in New Issue
Block a user