From 537a0993b04e752699e2dd4a0ba6d8f258e830c1 Mon Sep 17 00:00:00 2001 From: Mira Weller Date: Fri, 26 Jul 2024 19:40:28 +0200 Subject: [PATCH] add more detailed description of collect_potential_discounts parameter --- src/pretix/base/models/discount.py | 1 + src/pretix/base/services/pricing.py | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/pretix/base/models/discount.py b/src/pretix/base/models/discount.py index d506681822..11b677b7fd 100644 --- a/src/pretix/base/models/discount.py +++ b/src/pretix/base/models/discount.py @@ -337,6 +337,7 @@ class Discount(LoggedModel): :param positions: Dictionary mapping IDs to PositionInfo tuples. Bundled positions may not be included. + :param collect_potential_discounts: For detailed description, see pretix.base.services.pricing.apply_discounts :return: A dictionary mapping keys from the input dictionary to new prices. All positions contained in this dictionary are considered "consumed" and should not be considered diff --git a/src/pretix/base/services/pricing.py b/src/pretix/base/services/pricing.py index f3fa95cd90..3895b6b527 100644 --- a/src/pretix/base/services/pricing.py +++ b/src/pretix/base/services/pricing.py @@ -167,8 +167,12 @@ def apply_discounts(event: Event, sales_channel: Union[str, SalesChannel], :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. - + based on the "consumed" items, but lack matching "benefitting" items will be collected therein. + The dict will contain a mapping from index in the `positions` list of the item that could be consumed, to a list + of tuples describing the discounts that could be applied in the form (discount, max_count, grouping_id). + max_count is either the maximum number of benefitting items that the discount would apply to, or `inf` if that number + is not limited. The grouping_id can be used to distinguish several occurrences of the same discount. + :return: A list of ``(new_gross_price, discount)`` tuples in the same order as the input """ if isinstance(sales_channel, SalesChannel):