From 2c5b7acd5bd8c0fe71059bfda3a7716515e027c1 Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Fri, 18 Mar 2022 14:53:51 +0100 Subject: [PATCH] Allow to charge fees on addons --- pretix_servicefees/signals.py | 9 ++++++++- .../templates/pretix_servicefees/settings.html | 1 + pretix_servicefees/views.py | 4 ++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/pretix_servicefees/signals.py b/pretix_servicefees/signals.py index 285df12..59e3f0e 100644 --- a/pretix_servicefees/signals.py +++ b/pretix_servicefees/signals.py @@ -32,7 +32,11 @@ def navbar_settings(sender, request, **kwargs): def get_fees(event, total, invoice_address, mod='', request=None, positions=[], gift_cards=None): if request is not None and not positions: positions = get_cart(request) - positions = [pos for pos in positions if not pos.addon_to_id and pos.price != Decimal('0.00')] + positions = [pos for pos in positions if pos.price != Decimal('0.00')] + + skip_addons = event.settings.get('service_fee_skip_addons', as_type=bool) + if skip_addons: + positions = [pos for pos in positions if not pos.addon_to_id] skip_non_admission = event.settings.get('service_fee_skip_non_admission', as_type=bool) if skip_non_admission: @@ -156,3 +160,6 @@ def order_meta_signal(sender: Event, request: HttpRequest, **kwargs): except ResellerException: pass return meta + + +settings_hierarkey.add_default('service_fee_skip_addons', 'True', bool) \ No newline at end of file diff --git a/pretix_servicefees/templates/pretix_servicefees/settings.html b/pretix_servicefees/templates/pretix_servicefees/settings.html index e358df6..70e5005 100644 --- a/pretix_servicefees/templates/pretix_servicefees/settings.html +++ b/pretix_servicefees/templates/pretix_servicefees/settings.html @@ -10,6 +10,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_skip_addons 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 2c8c20d..6bd3f6b 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_addons = forms.BooleanField( + label=_('Do not charge per-ticket service fee on add-on products'), + required=False + ) service_fee_skip_non_admission = forms.BooleanField( label=_('Do not charge per-ticket service fee on non-admission products'), required=False