Discount: Respect addon grouping in line selection (Z#23220058) (#5782)

* Discount: Respect addon grouping in line selection (Z#23220058)

* Update src/pretix/base/models/discount.py

Co-authored-by: Richard Schreiber <schreiber@pretix.eu>

---------

Co-authored-by: Richard Schreiber <schreiber@pretix.eu>
This commit is contained in:
Raphael Michel
2026-01-16 15:23:59 +01:00
committed by GitHub
parent efb94265b2
commit 0259899e00
7 changed files with 83 additions and 12 deletions

View File

@@ -781,6 +781,39 @@ testcases_single_rule = [
)
),
# Distribute discounts somewhat equally over addon groups
(
(
Discount(
condition_min_count=3,
benefit_discount_matching_percent=20,
condition_apply_to_addons=True,
benefit_only_apply_to_cheapest_n_matches=1,
condition_ignore_voucher_discounted=True,
),
),
(
(2, 1, now(), Decimal('0.00'), None, False, Decimal('10.00')), # Main product
(1, 1, now(), Decimal('100.00'), 1, False, Decimal('0.00')),
(1, 1, now(), Decimal('100.00'), 1, False, Decimal('0.00')),
(1, 1, now(), Decimal('100.00'), 1, False, Decimal('0.00')),
(2, 1, now(), Decimal('0.00'), None, False, Decimal('10.00')), # Main product
(1, 1, now(), Decimal('100.00'), 2, False, Decimal('0.00')),
(1, 1, now(), Decimal('100.00'), 2, False, Decimal('0.00')),
(1, 1, now(), Decimal('100.00'), 2, False, Decimal('0.00')),
),
(
Decimal('0.00'),
Decimal('100.00'),
Decimal('100.00'),
Decimal('80.00'),
Decimal('0.00'),
Decimal('100.00'),
Decimal('100.00'),
Decimal('80.00'),
)
),
# Ignore bundled
(
(