From 1d05dd18abd01610bba1f9d1e64491ad9c578385 Mon Sep 17 00:00:00 2001 From: Martin Gross Date: Thu, 15 Feb 2024 10:30:19 +0100 Subject: [PATCH] get_fees: Add magic setting service_fee_skip_if_{pprovname} to allow arbitrary skipping of service fees --- pretix_servicefees/signals.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pretix_servicefees/signals.py b/pretix_servicefees/signals.py index b1d1eb7..031471b 100644 --- a/pretix_servicefees/signals.py +++ b/pretix_servicefees/signals.py @@ -84,6 +84,15 @@ def get_fees(event, total, invoice_address, mod='', request=None, positions=[], total -= fval summed += fval + # This hack allows any payment provider to declare a setting service_fee_skip_if_{pprovname} in order to implement + # the skipping of service fees when they are paid in their entirety through said payment provider/method. + # It is notably used by the KulturPass, which is for all intents and purposes a giftcard but handled like a regular + # payment provider. + if payment_requests is not None: + for p in payment_requests: + if event.settings.get(f'service_fee_skip_if_{p["provider"]}', default=False, as_type=bool): + total = max(0, total - Decimal(p['max_value'] or '0')) + if (fee_per_ticket or fee_abs or fee_percent) and total != Decimal('0.00'): tax_rule_zero = TaxRule.zero() fee = round_decimal(fee_abs + total * (fee_percent / 100) + len(positions) * fee_per_ticket, event.currency)