Introduce a setting to show net prices (#415)

* Introduce a setting to show net prices in the frontend

* Show net prices in the backend as well
This commit is contained in:
Raphael Michel
2017-02-22 16:59:54 +01:00
committed by GitHub
parent 08e7a29623
commit ed04f3124f
16 changed files with 206 additions and 43 deletions

View File

@@ -11,6 +11,7 @@ from django.utils.functional import cached_property
from django.utils.timezone import now from django.utils.timezone import now
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from pretix.base.decimal import round_decimal
from pretix.base.i18n import I18nCharField, I18nTextField from pretix.base.i18n import I18nCharField, I18nTextField
from pretix.base.models.base import LoggedModel from pretix.base.models.base import LoggedModel
@@ -221,6 +222,11 @@ class Item(LoggedModel):
if self.event: if self.event:
self.event.get_cache().clear() self.event.get_cache().clear()
@property
def default_price_net(self):
tax_value = round_decimal(self.default_price * (1 - 100 / (100 + self.tax_rate)))
return self.default_price - tax_value
def is_available(self, now_dt: datetime=None) -> bool: def is_available(self, now_dt: datetime=None) -> bool:
""" """
Returns whether this item is available according to its ``active`` flag Returns whether this item is available according to its ``active`` flag
@@ -313,6 +319,11 @@ class ItemVariation(models.Model):
def price(self): def price(self):
return self.default_price if self.default_price is not None else self.item.default_price return self.default_price if self.default_price is not None else self.item.default_price
@property
def net_price(self):
tax_value = round_decimal(self.price * (1 - 100 / (100 + self.item.tax_rate)))
return self.price - tax_value
def delete(self, *args, **kwargs): def delete(self, *args, **kwargs):
super().delete(*args, **kwargs) super().delete(*args, **kwargs)
if self.item: if self.item:

View File

@@ -7,10 +7,11 @@ from typing import List, Union
from django.conf import settings from django.conf import settings
from django.db import models from django.db import models
from django.db.models import F from django.db.models import F, Sum
from django.db.models.signals import post_delete from django.db.models.signals import post_delete
from django.dispatch import receiver from django.dispatch import receiver
from django.utils.crypto import get_random_string from django.utils.crypto import get_random_string
from django.utils.functional import cached_property
from django.utils.timezone import now from django.utils.timezone import now
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
@@ -215,6 +216,18 @@ class Order(LoggedModel):
else: else:
self.payment_fee_tax_value = Decimal('0.00') self.payment_fee_tax_value = Decimal('0.00')
@property
def payment_fee_net(self):
return self.payment_fee - self.payment_fee_tax_value
@cached_property
def tax_total(self):
return (self.positions.aggregate(s=Sum('tax_value'))['s'] or 0) + self.payment_fee_tax_value
@property
def net_total(self):
return self.total - self.tax_total
@staticmethod @staticmethod
def normalize_code(code): def normalize_code(code):
tr = str.maketrans({ tr = str.maketrans({
@@ -432,6 +445,10 @@ class AbstractPosition(models.Model):
else: else:
q.answer = "" q.answer = ""
@property
def net_price(self):
return self.price - self.tax_value
class OrderPosition(AbstractPosition): class OrderPosition(AbstractPosition):
""" """

View File

@@ -9,6 +9,7 @@ from django.db.models import Q
from django.utils.timezone import now from django.utils.timezone import now
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from pretix.base.decimal import round_decimal
from pretix.base.i18n import LazyLocaleException from pretix.base.i18n import LazyLocaleException
from pretix.base.models import ( from pretix.base.models import (
CartPosition, Event, Item, ItemVariation, Voucher, CartPosition, Event, Item, ItemVariation, Voucher,
@@ -143,6 +144,8 @@ class CartManager:
custom_price = Decimal(custom_price.replace(",", ".")) custom_price = Decimal(custom_price.replace(",", "."))
if custom_price > 100000000: if custom_price > 100000000:
return error_messages['price_too_high'] return error_messages['price_too_high']
if self.event.settings.display_net_prices:
custom_price = round_decimal(custom_price * (100 + item.tax_rate) / 100)
price = max(custom_price, price) price = max(custom_price, price)
return price return price

View File

@@ -20,6 +20,10 @@ DEFAULTS = {
'default': '10', 'default': '10',
'type': int 'type': int
}, },
'display_net_prices': {
'default': 'False',
'type': bool
},
'attendee_names_asked': { 'attendee_names_asked': {
'default': 'True', 'default': 'True',
'type': bool 'type': bool

View File

@@ -158,6 +158,12 @@ class EventSettingsForm(SettingsForm):
help_text=_("Show item details before presale has started and after presale has ended"), help_text=_("Show item details before presale has started and after presale has ended"),
required=False required=False
) )
display_net_prices = forms.BooleanField(
label=_("Show net prices instead of gross prices in the product list (not recommended!)"),
help_text=_("Independent of your choice, the cart will show gross prices as this the price that needs to be "
"paid"),
required=False
)
presale_start_show_date = forms.BooleanField( presale_start_show_date = forms.BooleanField(
label=_("Show start date"), label=_("Show start date"),
help_text=_("Show the presale start date before presale has started."), help_text=_("Show the presale start date before presale has started."),

View File

@@ -59,7 +59,7 @@ class OrderPositionChangeForm(forms.Form):
price = forms.DecimalField( price = forms.DecimalField(
required=False, required=False,
max_digits=10, decimal_places=2, max_digits=10, decimal_places=2,
label=_('New price') label=_('New price (gross)')
) )
operation = forms.ChoiceField( operation = forms.ChoiceField(
required=False, required=False,

View File

@@ -25,6 +25,7 @@
{% bootstrap_field sform.contact_mail layout="horizontal" %} {% bootstrap_field sform.contact_mail layout="horizontal" %}
{% bootstrap_field sform.imprint_url layout="horizontal" %} {% bootstrap_field sform.imprint_url layout="horizontal" %}
{% bootstrap_field sform.show_quota_left layout="horizontal" %} {% bootstrap_field sform.show_quota_left layout="horizontal" %}
{% bootstrap_field sform.display_net_prices layout="horizontal" %}
</fieldset> </fieldset>
<fieldset> <fieldset>
<legend>{% trans "Timeline" %}</legend> <legend>{% trans "Timeline" %}</legend>

View File

@@ -79,6 +79,9 @@
{% if position.form.operation.value == "price" %}checked="checked"{% endif %}> {% if position.form.operation.value == "price" %}checked="checked"{% endif %}>
{% trans "Change price to" %} {% trans "Change price to" %}
{% bootstrap_field position.form.price layout='inline' %} {% bootstrap_field position.form.price layout='inline' %}
{% if request.event.settings.display_net_prices %}
<em>{% trans "Enter a gross price including taxes." %}</em>
{% endif %}
</label> </label>
</div> </div>
<div class="radio"> <div class="radio">

View File

@@ -189,12 +189,20 @@
{% endif %} {% endif %}
</div> </div>
<div class="col-md-3 col-xs-6 price"> <div class="col-md-3 col-xs-6 price">
<strong>{{ event.currency }} {{ line.price|floatformat:2 }}</strong> {% if event.settings.display_net_prices %}
{% if line.tax_rate %} <strong>{{ event.currency }} {{ line.net_price|floatformat:2 }}</strong>
<br/> {% if line.tax_rate %}
<small>{% blocktrans trimmed with rate=line.tax_rate %} <br /><small>{% blocktrans trimmed with rate=line.tax_rate %}
<strong>plus</strong> {{ rate }}% taxes
{% endblocktrans %}</small>
{% endif %}
{% else %}
<strong>{{ event.currency }} {{ line.price|floatformat:2 }}</strong>
{% if line.tax_rate %}
<br /><small>{% blocktrans trimmed with rate=line.tax_rate %}
incl. {{ rate }}% taxes incl. {{ rate }}% taxes
{% endblocktrans %}</small> {% endblocktrans %}</small>
{% endif %}
{% endif %} {% endif %}
</div> </div>
<div class="clearfix"></div> <div class="clearfix"></div>
@@ -206,17 +214,47 @@
<strong>{% trans "Payment method fee" %}</strong> <strong>{% trans "Payment method fee" %}</strong>
</div> </div>
<div class="col-md-3 col-xs-6 col-md-offset-5 price"> <div class="col-md-3 col-xs-6 col-md-offset-5 price">
<strong>{{ event.currency }} {{ items.payment_fee|floatformat:2 }}</strong> {% if event.settings.display_net_prices %}
{% if order.payment_fee_tax_rate %} <strong>{{ event.currency }} {{ order.payment_fee_net|floatformat:2 }}</strong>
<br/> {% if order.payment_fee_tax_rate %}
<small>{% blocktrans trimmed with rate=order.payment_fee_tax_rate %} <br/>
incl. {{ rate }}% taxes <small>{% blocktrans trimmed with rate=order.payment_fee_tax_rate %}
{% endblocktrans %}</small> <strong>plus</strong> {{ rate }}% taxes
{% endblocktrans %}</small>
{% endif %}
{% else %}
<strong>{{ event.currency }} {{ items.payment_fee|floatformat:2 }}</strong>
{% if order.payment_fee_tax_rate %}
<br/>
<small>{% blocktrans trimmed with rate=order.payment_fee_tax_rate %}
incl. {{ rate }}% taxes
{% endblocktrans %}</small>
{% endif %}
{% endif %} {% endif %}
</div> </div>
<div class="clearfix"></div> <div class="clearfix"></div>
</div> </div>
{% endif %} {% endif %}
{% if event.settings.display_net_prices %}
<div class="row-fluid product-row total">
<div class="col-md-4 col-xs-6">
<strong>{% trans "Net total" %}</strong>
</div>
<div class="col-md-3 col-xs-6 col-md-offset-5 price">
{{ event.currency }} {{ items.net_total|floatformat:2 }}
</div>
<div class="clearfix"></div>
</div>
<div class="row-fluid product-row">
<div class="col-md-4 col-xs-6">
<strong>{% trans "Taxes" %}</strong>
</div>
<div class="col-md-3 col-xs-6 col-md-offset-5 price">
{{ event.currency }} {{ items.tax_total|floatformat:2 }}
</div>
<div class="clearfix"></div>
</div>
{% endif %}
<div class="row-fluid product-row total"> <div class="row-fluid product-row total">
<div class="col-md-4 col-xs-6"> <div class="col-md-4 col-xs-6">
<strong>{% trans "Total" %}</strong> <strong>{% trans "Total" %}</strong>

View File

@@ -179,6 +179,8 @@ class OrderDetail(OrderView):
'raw': cartpos, 'raw': cartpos,
'total': self.object.total, 'total': self.object.total,
'payment_fee': self.object.payment_fee, 'payment_fee': self.object.payment_fee,
'net_total': self.object.net_total,
'tax_total': self.object.tax_total,
} }

View File

@@ -70,22 +70,35 @@
<input type="hidden" name="item_{{ line.item.id }}" <input type="hidden" name="item_{{ line.item.id }}"
value="1" /> value="1" />
<input type="hidden" name="price_{{ line.item.id }}" <input type="hidden" name="price_{{ line.item.id }}"
value="{{ line.price }}" /> value="{% if event.settings.display_net_prices %}{{ line.net_price }}{% else %}{{ line.price }}{% endif %}" />
{% endif %} {% endif %}
<button class="btn btn-mini btn-link"><i class="fa fa-plus"></i></button> <button class="btn btn-mini btn-link"><i class="fa fa-plus"></i></button>
</form> </form>
{% endif %} {% endif %}
</div> </div>
<div class="singleprice price"> <div class="singleprice price">
{{ event.currency }} {{ line.price|floatformat:2 }} {% if event.settings.display_net_prices %}
{{ event.currency }} {{ line.net_price|floatformat:2 }}
{% else %}
{{ event.currency }} {{ line.price|floatformat:2 }}
{% endif %}
</div> </div>
{% endif %} {% endif %}
<div class="totalprice price"> <div class="totalprice price">
<strong>{{ event.currency }} {{ line.total|floatformat:2 }}</strong> {% if event.settings.display_net_prices %}
{% if line.tax_rate %} <strong>{{ event.currency }} {{ line.net_total|floatformat:2 }}</strong>
<br /><small>{% blocktrans trimmed with rate=line.tax_rate %} {% if line.tax_rate %}
incl. {{ rate }}% taxes <br /><small>{% blocktrans trimmed with rate=line.tax_rate %}
{% endblocktrans %}</small> <strong>plus</strong> {{ rate }}% taxes
{% endblocktrans %}</small>
{% endif %}
{% else %}
<strong>{{ event.currency }} {{ line.total|floatformat:2 }}</strong>
{% if line.tax_rate %}
<br /><small>{% blocktrans trimmed with rate=line.tax_rate %}
incl. {{ rate }}% taxes
{% endblocktrans %}</small>
{% endif %}
{% endif %} {% endif %}
</div> </div>
{% if download %} {% if download %}
@@ -102,23 +115,52 @@
</div> </div>
{% endfor %} {% endfor %}
{% if cart.payment_fee %} {% if cart.payment_fee %}
{# TODO: Tax rate? #}
<div class="row cart-row"> <div class="row cart-row">
<div class="col-md-4 col-xs-6"> <div class="col-md-4 col-xs-6">
<strong>{% trans "Payment method fee" %}</strong> <strong>{% trans "Payment method fee" %}</strong>
</div> </div>
<div class="col-md-3 col-xs-6 col-md-offset-5 price"> <div class="col-md-3 col-xs-6 col-md-offset-5 price">
<strong>{{ event.currency }} {{ cart.payment_fee|floatformat:2 }}</strong> {% if event.settings.display_net_prices %}
{% if cart.payment_fee_tax_rate %} <strong>{{ event.currency }} {{ cart.payment_fee_net|floatformat:2 }}</strong>
<br/> {% if cart.payment_fee_tax_rate %}
<small>{% blocktrans trimmed with rate=cart.payment_fee_tax_rate %} <br/>
incl. {{ rate }}% taxes <small>{% blocktrans trimmed with rate=cart.payment_fee_tax_rate %}
{% endblocktrans %}</small> <strong>plus</strong> {{ rate }}% taxes
{% endblocktrans %}</small>
{% endif %}
{% else %}
<strong>{{ event.currency }} {{ cart.payment_fee|floatformat:2 }}</strong>
{% if cart.payment_fee_tax_rate %}
<br/>
<small>{% blocktrans trimmed with rate=cart.payment_fee_tax_rate %}
incl. {{ rate }}% taxes
{% endblocktrans %}</small>
{% endif %}
{% endif %} {% endif %}
</div> </div>
<div class="clearfix"></div> <div class="clearfix"></div>
</div> </div>
{% endif %} {% endif %}
{% if event.settings.display_net_prices %}
<div class="row cart-row total">
<div class="col-md-4 col-xs-6">
<strong>{% trans "Net total" %}</strong>
</div>
<div class="col-md-3 col-xs-6 col-md-offset-5 price">
{{ event.currency }} {{ cart.net_total|floatformat:2 }}
</div>
<div class="clearfix"></div>
</div>
<div class="row cart-row">
<div class="col-md-4 col-xs-6">
<strong>{% trans "Taxes" %}</strong>
</div>
<div class="col-md-3 col-xs-6 col-md-offset-5 price">
{{ event.currency }} {{ cart.tax_total|floatformat:2 }}
</div>
<div class="clearfix"></div>
</div>
{% endif %}
<div class="row cart-row total"> <div class="row cart-row total">
<div class="col-md-4 col-xs-6"> <div class="col-md-4 col-xs-6">
<strong>{% trans "Total" %}</strong> <strong>{% trans "Total" %}</strong>

View File

@@ -136,14 +136,18 @@
<span class="input-group-addon">{{ event.currency }}</span> <span class="input-group-addon">{{ event.currency }}</span>
<input type="number" class="form-control input-item-price" <input type="number" class="form-control input-item-price"
placeholder="0" placeholder="0"
min="{{ var.price|stringformat:"0.2f" }}" min="{{ var.display_price|stringformat:"0.2f" }}"
name="price_{{ item.id }}_{{ var.id }}" name="price_{{ item.id }}_{{ var.id }}"
step="any" value="{{ var.price|stringformat:"0.2f" }}"> step="any" value="{{ var.display_price|stringformat:"0.2f" }}">
</div> </div>
{% else %} {% else %}
{{ event.currency }} {{ var.price|floatformat:2 }} {{ event.currency }} {{ var.display_price|floatformat:2 }}
{% endif %} {% endif %}
{% if item.tax_rate %} {% if item.tax_rate and event.settings.display_net_prices %}
<small>{% blocktrans trimmed with rate=item.tax_rate %}
<strong>plus</strong> {{ rate }}% taxes
{% endblocktrans %}</small>
{% elif item.tax_rate %}
<small>{% blocktrans trimmed with rate=item.tax_rate %} <small>{% blocktrans trimmed with rate=item.tax_rate %}
incl. {{ rate }}% taxes incl. {{ rate }}% taxes
{% endblocktrans %}</small> {% endblocktrans %}</small>
@@ -186,14 +190,18 @@
<div class="input-group input-group-price"> <div class="input-group input-group-price">
<span class="input-group-addon">{{ event.currency }}</span> <span class="input-group-addon">{{ event.currency }}</span>
<input type="number" class="form-control input-item-price" placeholder="0" <input type="number" class="form-control input-item-price" placeholder="0"
min="{{ item.price|stringformat:"0.2f" }}" min="{{ item.display_price|stringformat:"0.2f" }}"
name="price_{{ item.id }}" name="price_{{ item.id }}"
step="any" value="{{ item.price|stringformat:"0.2f" }}"> step="any" value="{{ item.display_price|stringformat:"0.2f" }}">
</div> </div>
{% else %} {% else %}
{{ event.currency }} {{ item.price|floatformat:2 }} {{ event.currency }} {{ item.display_price|floatformat:2 }}
{% endif %} {% endif %}
{% if item.tax_rate %} {% if item.tax_rate and event.settings.display_net_prices %}
<small>{% blocktrans trimmed with rate=item.tax_rate %}
<strong>plus</strong> {{ rate }}% taxes
{% endblocktrans %}</small>
{% elif item.tax_rate %}
<small>{% blocktrans trimmed with rate=item.tax_rate %} <small>{% blocktrans trimmed with rate=item.tax_rate %}
incl. {{ rate }}% taxes incl. {{ rate }}% taxes
{% endblocktrans %}</small> {% endblocktrans %}</small>

View File

@@ -72,7 +72,11 @@
{% else %} {% else %}
{{ event.currency }} {{ var.display_price|floatformat:2 }} {{ event.currency }} {{ var.display_price|floatformat:2 }}
{% endif %} {% endif %}
{% if item.tax_rate %} {% if item.tax_rate and event.settings.display_net_prices %}
<small>{% blocktrans trimmed with rate=item.tax_rate %}
<strong>plus</strong> {{ rate }}% taxes
{% endblocktrans %}</small>
{% elif item.tax_rate %}
<small>{% blocktrans trimmed with rate=item.tax_rate %} <small>{% blocktrans trimmed with rate=item.tax_rate %}
incl. {{ rate }}% taxes incl. {{ rate }}% taxes
{% endblocktrans %}</small> {% endblocktrans %}</small>
@@ -126,7 +130,11 @@
{% else %} {% else %}
{{ event.currency }} {{ item.price|floatformat:2 }} {{ event.currency }} {{ item.price|floatformat:2 }}
{% endif %} {% endif %}
{% if item.tax_rate %} {% if item.tax_rate and event.settings.display_net_prices %}
<small>{% blocktrans trimmed with rate=item.tax_rate %}
<strong>plus</strong> {{ rate }}% taxes
{% endblocktrans %}</small>
{% elif item.tax_rate %}
<small>{% blocktrans trimmed with rate=item.tax_rate %} <small>{% blocktrans trimmed with rate=item.tax_rate %}
incl. {{ rate }}% taxes incl. {{ rate }}% taxes
{% endblocktrans %}</small> {% endblocktrans %}</small>

View File

@@ -6,6 +6,7 @@ from django.db.models import Sum
from django.utils.functional import cached_property from django.utils.functional import cached_property
from django.utils.timezone import now from django.utils.timezone import now
from pretix.base.decimal import round_decimal
from pretix.base.models import CartPosition, OrderPosition from pretix.base.models import CartPosition, OrderPosition
from pretix.base.signals import register_payment_providers from pretix.base.signals import register_payment_providers
@@ -44,10 +45,10 @@ class CartMixin:
else: else:
i = pos.pk i = pos.pk
if downloads: if downloads:
return i, pos.pk, 0, 0, 0, 0 return i, pos.pk, 0, 0, 0, 0,
if answers and ((pos.item.admission and self.request.event.settings.attendee_names_asked) if answers and ((pos.item.admission and self.request.event.settings.attendee_names_asked)
or pos.item.questions.all()): or pos.item.questions.all()):
return i, pos.pk, 0, 0, 0, 0 return i, pos.pk, 0, 0, 0, 0,
return 0, 0, pos.item_id, pos.variation_id, pos.price, (pos.voucher_id or 0) return 0, 0, pos.item_id, pos.variation_id, pos.price, (pos.voucher_id or 0)
positions = [] positions = []
@@ -56,15 +57,24 @@ class CartMixin:
group = g[0] group = g[0]
group.count = len(g) group.count = len(g)
group.total = group.count * group.price group.total = group.count * group.price
group.net_total = group.count * group.net_price
group.has_questions = answers and k[0] != "" group.has_questions = answers and k[0] != ""
if answers: if answers:
group.cache_answers() group.cache_answers()
positions.append(group) positions.append(group)
total = sum(p.total for p in positions) total = sum(p.total for p in positions)
net_total = sum(p.net_total for p in positions)
tax_total = sum(p.total - p.net_total for p in positions)
payment_fee = payment_fee if payment_fee is not None else self.get_payment_fee(total) payment_fee = payment_fee if payment_fee is not None else self.get_payment_fee(total)
payment_fee_tax_rate = payment_fee_tax_rate if payment_fee_tax_rate is not None else self.request.event.settings.tax_rate_default payment_fee_tax_rate = round_decimal(payment_fee_tax_rate
if payment_fee_tax_rate is not None
else self.request.event.settings.tax_rate_default)
payment_fee_tax_value = round_decimal(payment_fee * (1 - 100 / (100 + payment_fee_tax_rate)))
payment_fee_net = payment_fee - payment_fee_tax_value
tax_total += payment_fee_tax_value
net_total += payment_fee_net
try: try:
first_expiry = min(p.expires for p in positions) if positions else now() first_expiry = min(p.expires for p in positions) if positions else now()
@@ -77,7 +87,10 @@ class CartMixin:
'positions': positions, 'positions': positions,
'raw': cartpos, 'raw': cartpos,
'total': total + payment_fee, 'total': total + payment_fee,
'net_total': net_total,
'tax_total': tax_total,
'payment_fee': payment_fee, 'payment_fee': payment_fee,
'payment_fee_net': payment_fee_net,
'payment_fee_tax_rate': payment_fee_tax_rate, 'payment_fee_tax_rate': payment_fee_tax_rate,
'answers': answers, 'answers': answers,
'minutes_left': minutes_left, 'minutes_left': minutes_left,

View File

@@ -6,6 +6,7 @@ from django.utils.timezone import now
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from django.views.generic import TemplateView, View from django.views.generic import TemplateView, View
from pretix.base.decimal import round_decimal
from pretix.base.models import CartPosition, Quota, Voucher from pretix.base.models import CartPosition, Quota, Voucher
from pretix.base.services.cart import ( from pretix.base.services.cart import (
CartError, add_items_to_cart, remove_items_from_cart, CartError, add_items_to_cart, remove_items_from_cart,
@@ -189,6 +190,8 @@ class RedeemView(EventViewMixin, TemplateView):
else: else:
item.cached_availability = item.check_quotas() item.cached_availability = item.check_quotas()
item.price = self.voucher.calculate_price(item.default_price) item.price = self.voucher.calculate_price(item.default_price)
if self.request.event.settings.display_net_prices:
item.price -= round_decimal(item.price * (1 - 100 / (100 + item.tax_rate)))
else: else:
for var in item.available_variations: for var in item.available_variations:
if self.voucher.allow_ignore_quota or self.voucher.block_quota: if self.voucher.allow_ignore_quota or self.voucher.block_quota:
@@ -196,10 +199,12 @@ class RedeemView(EventViewMixin, TemplateView):
else: else:
var.cached_availability = list(var.check_quotas()) var.cached_availability = list(var.check_quotas())
var.display_price = self.voucher.calculate_price(var.price) var.display_price = self.voucher.calculate_price(var.price)
if self.request.event.settings.display_net_prices:
var.display_price -= round_decimal(var.display_price * (1 - 100 / (100 + item.tax_rate)))
if len(item.available_variations) > 0: if len(item.available_variations) > 0:
item.min_price = min([v.price for v in item.available_variations]) item.min_price = min([v.display_price for v in item.available_variations])
item.max_price = max([v.price for v in item.available_variations]) item.max_price = max([v.display_price for v in item.available_variations])
items = [item for item in items if len(item.available_variations) > 0 or not item.has_variations] items = [item for item in items if len(item.available_variations) > 0 or not item.has_variations]
context['options'] = sum([(len(item.available_variations) if item.has_variations else 1) context['options'] = sum([(len(item.available_variations) if item.has_variations else 1)

View File

@@ -63,6 +63,7 @@ def get_grouped_items(event):
if item.cached_availability[1] is not None else sys.maxsize, if item.cached_availability[1] is not None else sys.maxsize,
int(event.settings.max_items_per_order)) int(event.settings.max_items_per_order))
item.price = item.default_price item.price = item.default_price
item.display_price = item.default_price_net if event.settings.display_net_prices else item.price
display_add_to_cart = display_add_to_cart or item.order_max > 0 display_add_to_cart = display_add_to_cart or item.order_max > 0
else: else:
for var in item.available_variations: for var in item.available_variations:
@@ -70,10 +71,11 @@ def get_grouped_items(event):
var.order_max = min(var.cached_availability[1] var.order_max = min(var.cached_availability[1]
if var.cached_availability[1] is not None else sys.maxsize, if var.cached_availability[1] is not None else sys.maxsize,
int(event.settings.max_items_per_order)) int(event.settings.max_items_per_order))
var.display_price = var.net_price if event.settings.display_net_prices else var.price
display_add_to_cart = display_add_to_cart or var.order_max > 0 display_add_to_cart = display_add_to_cart or var.order_max > 0
if len(item.available_variations) > 0: if len(item.available_variations) > 0:
item.min_price = min([v.price for v in item.available_variations]) item.min_price = min([v.display_price for v in item.available_variations])
item.max_price = max([v.price for v in item.available_variations]) item.max_price = max([v.display_price for v in item.available_variations])
items = [item for item in items if len(item.available_variations) > 0 or not item.has_variations] items = [item for item in items if len(item.available_variations) > 0 or not item.has_variations]
return items, display_add_to_cart return items, display_add_to_cart