Compare commits

...

1 Commits

Author SHA1 Message Date
Raphael Michel
e54fec3da8 Do not use price suggestion if voucher is used (Z#23155018) 2024-06-03 13:58:21 +02:00
2 changed files with 11 additions and 5 deletions

View File

@@ -444,7 +444,8 @@ class Item(LoggedModel):
free_price_suggestion = models.DecimalField( free_price_suggestion = models.DecimalField(
verbose_name=_("Suggested price"), 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 " 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, max_digits=13, decimal_places=2, null=True, blank=True,
) )
tax_rule = models.ForeignKey( tax_rule = models.ForeignKey(
@@ -1086,7 +1087,8 @@ class ItemVariation(models.Model):
free_price_suggestion = models.DecimalField( free_price_suggestion = models.DecimalField(
verbose_name=_("Suggested price"), 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 " 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, max_digits=13, decimal_places=2, null=True, blank=True,
) )
require_approval = models.BooleanField( 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) original_price = item_price_override.get(item.pk, item.default_price)
voucher_reduced = False
if voucher: if voucher:
price = voucher.calculate_price(original_price) price = voucher.calculate_price(original_price)
voucher_reduced = price < original_price
include_bundled = not voucher.all_bundles_included include_bundled = not voucher.all_bundles_included
else: else:
price = original_price price = original_price
include_bundled = True include_bundled = True
item.display_price = item.tax(price, currency=event.currency, include_bundled=include_bundled) 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) item.suggested_price = item.tax(max(price, item.free_price_suggestion), currency=event.currency, include_bundled=include_bundled)
else: else:
item.suggested_price = item.display_price 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) original_price = var_price_override.get(var.pk, var.price)
voucher_reduced = False
if voucher: if voucher:
price = voucher.calculate_price(original_price) price = voucher.calculate_price(original_price)
voucher_reduced = price < original_price
include_bundled = not voucher.all_bundles_included include_bundled = not voucher.all_bundles_included
else: else:
price = original_price 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) 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, var.suggested_price = item.tax(max(price, var.free_price_suggestion), currency=event.currency,
include_bundled=include_bundled) 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, var.suggested_price = item.tax(max(price, item.free_price_suggestion), currency=event.currency,
include_bundled=include_bundled) include_bundled=include_bundled)
else: else: