Free price: Allow to suggest a different price than the minimum (#3666)

* Free price: Allow to suggest a different price than the minimum

* Full implementation

* Widget tests

* Add min values to titles
This commit is contained in:
Raphael Michel
2023-10-27 13:36:01 +02:00
committed by GitHub
parent b32249d48b
commit 000c64755d
18 changed files with 205 additions and 23 deletions

View File

@@ -300,6 +300,10 @@ def get_grouped_items(event, subevent=None, voucher=None, channel='web', require
price = original_price
item.display_price = item.tax(price, currency=event.currency, include_bundled=True)
if item.free_price and item.free_price_suggestion is not None:
item.suggested_price = item.tax(max(price, item.free_price_suggestion), currency=event.currency, include_bundled=True)
else:
item.suggested_price = item.display_price
if price != original_price:
item.original_price = item.tax(original_price, currency=event.currency, include_bundled=True)
@@ -346,6 +350,15 @@ def get_grouped_items(event, subevent=None, voucher=None, channel='web', require
var.display_price = var.tax(price, currency=event.currency, include_bundled=True)
if item.free_price and var.free_price_suggestion is not None:
var.suggested_price = item.tax(max(price, var.free_price_suggestion), currency=event.currency,
include_bundled=True)
elif item.free_price and item.free_price_suggestion is not None:
var.suggested_price = item.tax(max(price, item.free_price_suggestion), currency=event.currency,
include_bundled=True)
else:
var.suggested_price = var.display_price
if price != original_price:
var.original_price = var.tax(original_price, currency=event.currency, include_bundled=True)
else:

View File

@@ -1355,7 +1355,7 @@ class OrderChangeMixin:
rate=a.tax_rate,
)
else:
v.initial_price = v.display_price
v.initial_price = v.suggested_price
i.expand = any(v.initial for v in i.available_variations)
else:
i.initial = len(current_addon_products[i.pk, None])
@@ -1369,7 +1369,7 @@ class OrderChangeMixin:
rate=a.tax_rate,
)
else:
i.initial_price = i.display_price
i.initial_price = i.suggested_price
if items:
p.addon_form['categories'].append({

View File

@@ -274,6 +274,7 @@ class WidgetAPIProductList(EventListMixin, View):
'order_min': item.min_per_order,
'order_max': item.order_max if not item.has_variations else None,
'price': price_dict(item, item.display_price) if not item.has_variations else None,
'suggested_price': price_dict(item, item.suggested_price) if not item.has_variations else None,
'min_price': item.min_price if item.has_variations else None,
'max_price': item.max_price if item.has_variations else None,
'allow_waitinglist': item.allow_waitinglist,
@@ -296,6 +297,7 @@ class WidgetAPIProductList(EventListMixin, View):
'order_max': var.order_max,
'description': str(rich_text(var.description, safelinks=False)) if var.description else None,
'price': price_dict(item, var.display_price),
'suggested_price': price_dict(item, var.suggested_price),
'original_price': (
(
var.original_price.net