updated from Atlas
This commit is contained in:
@@ -1,20 +1,25 @@
|
||||
def fidelity_promo(order):
|
||||
from decimal import Decimal
|
||||
from strategy import Order
|
||||
|
||||
def fidelity_promo(order: Order) -> Decimal: # <3>
|
||||
"""5% discount for customers with 1000 or more fidelity points"""
|
||||
return order.total() * 0.05 if order.customer.fidelity >= 1000 else 0
|
||||
if order.customer.fidelity >= 1000:
|
||||
return order.total() * Decimal('0.05')
|
||||
return Decimal(0)
|
||||
|
||||
|
||||
def bulk_item_promo(order):
|
||||
def bulk_item_promo(order: Order) -> Decimal:
|
||||
"""10% discount for each LineItem with 20 or more units"""
|
||||
discount = 0
|
||||
discount = Decimal(0)
|
||||
for item in order.cart:
|
||||
if item.quantity >= 20:
|
||||
discount += item.total() * 0.1
|
||||
discount += item.total() * Decimal('0.1')
|
||||
return discount
|
||||
|
||||
|
||||
def large_order_promo(order):
|
||||
def large_order_promo(order: Order) -> Decimal:
|
||||
"""7% discount for orders with 10 or more distinct items"""
|
||||
distinct_items = {item.product for item in order.cart}
|
||||
if len(distinct_items) >= 10:
|
||||
return order.total() * 0.07
|
||||
return 0
|
||||
return order.total() * Decimal('0.07')
|
||||
return Decimal(0)
|
||||
|
||||
Reference in New Issue
Block a user