diff --git a/src/pretix/base/migrations/0269_itemcategory_cross_selling.py b/src/pretix/base/migrations/0270_itemcategory_cross_selling.py similarity index 90% rename from src/pretix/base/migrations/0269_itemcategory_cross_selling.py rename to src/pretix/base/migrations/0270_itemcategory_cross_selling.py index c183066224..33dc5a2608 100644 --- a/src/pretix/base/migrations/0269_itemcategory_cross_selling.py +++ b/src/pretix/base/migrations/0270_itemcategory_cross_selling.py @@ -8,7 +8,7 @@ import pretix.base.models.orders class Migration(migrations.Migration): dependencies = [ - ("pretixbase", "0268_remove_subevent_items_remove_subevent_variations_and_more"), + ("pretixbase", "0269_order_api_meta"), ] operations = [ diff --git a/src/pretix/base/models/discount.py b/src/pretix/base/models/discount.py index d6fc6ca18a..d506681822 100644 --- a/src/pretix/base/models/discount.py +++ b/src/pretix/base/models/discount.py @@ -307,11 +307,9 @@ class Discount(LoggedModel): n_groups * self.condition_min_count: possible_applications_cond * self.condition_min_count ]): - print(i, idx) collect_potential_discounts[idx] += [ (self, self.benefit_only_apply_to_cheapest_n_matches, i // self.condition_min_count) ] - print(collect_potential_discounts) else: consume_idx = condition_idx_group diff --git a/src/pretix/base/services/pricing.py b/src/pretix/base/services/pricing.py index 2c71f7db88..f3fa95cd90 100644 --- a/src/pretix/base/services/pricing.py +++ b/src/pretix/base/services/pricing.py @@ -20,6 +20,7 @@ # . # import re +from collections import defaultdict from decimal import Decimal from typing import List, Optional, Tuple, Union @@ -158,13 +159,16 @@ def get_line_price(price_after_voucher: Decimal, custom_price_input: Decimal, cu def apply_discounts(event: Event, sales_channel: Union[str, SalesChannel], positions: List[Tuple[int, Optional[int], Decimal, bool, bool, Decimal]], - collect_potential_discounts=None) -> List[Tuple[Decimal, Optional[Discount]]]: + collect_potential_discounts: Optional[defaultdict]=None) -> List[Tuple[Decimal, Optional[Discount]]]: """ Applies any dynamic discounts to a cart :param event: Event the cart belongs to :param sales_channel: Sales channel the cart was created with :param positions: Tuple of the form ``(item_id, subevent_id, line_price_gross, is_addon_to, is_bundled, voucher_discount)`` + :param collect_potential_discounts: If a `defaultdict(list)` is supplied, all discounts that could be applied to the cart + based on the "consumed" items, but lack matching "benefitting" items will be collected in it. + :return: A list of ``(new_gross_price, discount)`` tuples in the same order as the input """ if isinstance(sales_channel, SalesChannel):