diff --git a/src/pretix/base/services/pricing.py b/src/pretix/base/services/pricing.py index e95d771b6..06433f3cf 100644 --- a/src/pretix/base/services/pricing.py +++ b/src/pretix/base/services/pricing.py @@ -47,8 +47,6 @@ def get_price(item: Item, variation: ItemVariation = None, eu_reverse_charge=False, ) - price = tax_rule.tax(price, invoice_address=invoice_address, subtract_from_gross=bundled_sum) - if force_custom_price and custom_price is not None and custom_price != "": if custom_price_is_net: price = tax_rule.tax(custom_price, base_price_is='net', invoice_address=invoice_address, @@ -56,17 +54,22 @@ def get_price(item: Item, variation: ItemVariation = None, else: price = tax_rule.tax(custom_price, base_price_is='gross', invoice_address=invoice_address, subtract_from_gross=bundled_sum) - if item.free_price and custom_price is not None and custom_price != "": + elif item.free_price and custom_price is not None and custom_price != "": if not isinstance(custom_price, Decimal): custom_price = Decimal(str(custom_price).replace(",", ".")) if custom_price > 100000000: raise ValueError('price_too_high') + + price = tax_rule.tax(price, invoice_address=invoice_address) + if custom_price_is_net: price = tax_rule.tax(max(custom_price, price.net), base_price_is='net', invoice_address=invoice_address, subtract_from_gross=bundled_sum) else: price = tax_rule.tax(max(custom_price, price.gross), base_price_is='gross', invoice_address=invoice_address, subtract_from_gross=bundled_sum) + else: + price = tax_rule.tax(price, invoice_address=invoice_address, subtract_from_gross=bundled_sum) price.gross = round_decimal(price.gross, item.event.currency) price.net = round_decimal(price.net, item.event.currency) diff --git a/src/tests/presale/test_cart.py b/src/tests/presale/test_cart.py index 10304cbe0..0cf16bf0e 100644 --- a/src/tests/presale/test_cart.py +++ b/src/tests/presale/test_cart.py @@ -2722,6 +2722,27 @@ class CartBundleTest(CartTestMixin, TestCase): assert a.item == self.trans assert a.price == 1.5 + @classscope(attr='orga') + def test_simple_bundle_main_enforce_free_price_minimum(self): + self.ticket.free_price = True + self.ticket.save() + self.cm.add_new_items([ + { + 'item': self.ticket.pk, + 'variation': None, + 'price': '21.50', + 'count': 1 + } + ]) + self.cm.commit() + cp = CartPosition.objects.get(addon_to__isnull=True) + assert cp.item == self.ticket + assert cp.price == 23 - 1.5 + assert cp.addons.count() == 1 + a = cp.addons.get() + assert a.item == self.trans + assert a.price == 1.5 + @classscope(attr='orga') def test_voucher_on_base_product(self): v = self.event.vouchers.create(code="foo", item=self.ticket)