Coverage for /home/chris/workspace/django-shop/shop/cart/modifiers/rebate_modifiers: 100.00%

# Coverage for /home/chris/workspace/django-shop/shop/cart/modifiers/rebate_modifiers : 100.00%

## 11 statements 11 run 0 missing 0 excluded 0 partial

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | #-*- coding: utf-8 -*- from decimal import Decimal from shop.cart.cart_modifiers_base import BaseCartModifier class BulkRebateModifier(BaseCartModifier): def get_extra_cart_item_price_field(self, cart_item): """ Add a rebate to a line item depending on the quantity ordered: This serves as an example mass rebate modifier: if you buy more than 5 items of the same kind, you get 10% off the bunch >>> cart_item.extra_price_fields.update({'Rebate': Decimal('10.0')}) """ REBATE_PERCENTAGE = Decimal('10') NUMBER_OF_ITEMS_TO_TRIGGER_REBATE = 5 result_tuple = None if cart_item.quantity >= NUMBER_OF_ITEMS_TO_TRIGGER_REBATE: rebate = (REBATE_PERCENTAGE/100) * cart_item.line_subtotal result_tuple = ('Rebate', -rebate) return result_tuple # Returning None is ok