Do not use price suggestion if voucher is used (Z#23155018) (#4195)

This commit is contained in:
Raphael Michel
2024-06-04 11:57:26 +02:00
committed by GitHub
parent dd7ee84d29
commit d463878514
2 changed files with 11 additions and 5 deletions

View File

@@ -444,7 +444,8 @@ class Item(LoggedModel):
free_price_suggestion = models.DecimalField(
verbose_name=_("Suggested price"),
help_text=_("This price will be used as the default value of the input field. The user can choose a lower "
"value, but not lower than the price this product would have without the free price option."),
"value, but not lower than the price this product would have without the free price option. This "
"will be ignored if a voucher is used that lowers the price."),
max_digits=13, decimal_places=2, null=True, blank=True,
)
tax_rule = models.ForeignKey(
@@ -1086,7 +1087,8 @@ class ItemVariation(models.Model):
free_price_suggestion = models.DecimalField(
verbose_name=_("Suggested price"),
help_text=_("This price will be used as the default value of the input field. The user can choose a lower "
"value, but not lower than the price this product would have without the free price option."),
"value, but not lower than the price this product would have without the free price option. This "
"will be ignored if a voucher is used that lowers the price."),
max_digits=13, decimal_places=2, null=True, blank=True,
)
require_approval = models.BooleanField(

View File

@@ -348,15 +348,17 @@ def get_grouped_items(event, subevent=None, voucher=None, channel='web', require
)
original_price = item_price_override.get(item.pk, item.default_price)
voucher_reduced = False
if voucher:
price = voucher.calculate_price(original_price)
voucher_reduced = price < original_price
include_bundled = not voucher.all_bundles_included
else:
price = original_price
include_bundled = True
item.display_price = item.tax(price, currency=event.currency, include_bundled=include_bundled)
if item.free_price and item.free_price_suggestion is not None:
if item.free_price and item.free_price_suggestion is not None and not voucher_reduced:
item.suggested_price = item.tax(max(price, item.free_price_suggestion), currency=event.currency, include_bundled=include_bundled)
else:
item.suggested_price = item.display_price
@@ -399,8 +401,10 @@ def get_grouped_items(event, subevent=None, voucher=None, channel='web', require
)
original_price = var_price_override.get(var.pk, var.price)
voucher_reduced = False
if voucher:
price = voucher.calculate_price(original_price)
voucher_reduced = price < original_price
include_bundled = not voucher.all_bundles_included
else:
price = original_price
@@ -408,10 +412,10 @@ def get_grouped_items(event, subevent=None, voucher=None, channel='web', require
var.display_price = var.tax(price, currency=event.currency, include_bundled=include_bundled)
if item.free_price and var.free_price_suggestion is not None:
if item.free_price and var.free_price_suggestion is not None and not voucher_reduced:
var.suggested_price = item.tax(max(price, var.free_price_suggestion), currency=event.currency,
include_bundled=include_bundled)
elif item.free_price and item.free_price_suggestion is not None:
elif item.free_price and item.free_price_suggestion is not None and not voucher_reduced:
var.suggested_price = item.tax(max(price, item.free_price_suggestion), currency=event.currency,
include_bundled=include_bundled)
else: