From f31b03ac4136401ae03a056e8bf0c784445ca7d9 Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Fri, 18 Mar 2022 14:52:26 +0100 Subject: [PATCH] Allow to limit per-ticket fee to admission products --- pretix_servicefees/signals.py | 5 +++++ .../templates/pretix_servicefees/settings.html | 1 + pretix_servicefees/views.py | 4 ++++ 3 files changed, 10 insertions(+) diff --git a/pretix_servicefees/signals.py b/pretix_servicefees/signals.py index 124d41c..285df12 100644 --- a/pretix_servicefees/signals.py +++ b/pretix_servicefees/signals.py @@ -7,6 +7,7 @@ from django.utils.translation import gettext_lazy as _, gettext, get_language from pretix.base.decimal import round_decimal from pretix.base.models import Event, Order, TaxRule from pretix.base.models.orders import OrderFee +from pretix.base.settings import settings_hierarkey from pretix.base.signals import order_fee_calculation from pretix.base.templatetags.money import money_filter from pretix.control.signals import nav_event_settings @@ -33,6 +34,10 @@ def get_fees(event, total, invoice_address, mod='', request=None, positions=[], positions = get_cart(request) positions = [pos for pos in positions if not pos.addon_to_id and pos.price != Decimal('0.00')] + skip_non_admission = event.settings.get('service_fee_skip_non_admission', as_type=bool) + if skip_non_admission: + positions = [pos for pos in positions if pos.item.admission] + fee_per_ticket = event.settings.get('service_fee_per_ticket' + mod, as_type=Decimal) if mod and fee_per_ticket is None: fee_per_ticket = event.settings.get('service_fee_per_ticket', as_type=Decimal) diff --git a/pretix_servicefees/templates/pretix_servicefees/settings.html b/pretix_servicefees/templates/pretix_servicefees/settings.html index b67cb78..e358df6 100644 --- a/pretix_servicefees/templates/pretix_servicefees/settings.html +++ b/pretix_servicefees/templates/pretix_servicefees/settings.html @@ -9,6 +9,7 @@
{% trans "Service fees" %} {% bootstrap_field form.service_fee_per_ticket addon_after=request.event.currency layout="control" %} + {% bootstrap_field form.service_fee_skip_non_admission layout="control" %} {% bootstrap_field form.service_fee_abs addon_after=request.event.currency layout="control" %} {% bootstrap_field form.service_fee_percent addon_after="%" layout="control" %} {% bootstrap_field form.service_fee_skip_if_gift_card layout="control" %} diff --git a/pretix_servicefees/views.py b/pretix_servicefees/views.py index ec60305..2c8c20d 100644 --- a/pretix_servicefees/views.py +++ b/pretix_servicefees/views.py @@ -33,6 +33,10 @@ class ServiceFeeSettingsForm(SettingsForm): 'submitted, not if it\'s used to pay an unpaid order later.'), required=False ) + service_fee_skip_non_admission = forms.BooleanField( + label=_('Do not charge per-ticket service fee on non-admission products'), + required=False + ) service_fee_abs_resellers = forms.DecimalField( label=_('Fixed fee per order'),