From d8d00a7e262e2c17f474d2da0a2f419c0669a13d Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Wed, 28 Feb 2018 21:03:38 +0100 Subject: [PATCH] Add total argument to fee calculation signals --- src/pretix/base/services/cart.py | 3 ++- src/pretix/base/services/orders.py | 4 ++-- src/pretix/base/signals.py | 6 ++++-- src/pretix/presale/signals.py | 5 +++-- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/pretix/base/services/cart.py b/src/pretix/base/services/cart.py index 71155f80f..94cdb481d 100644 --- a/src/pretix/base/services/cart.py +++ b/src/pretix/base/services/cart.py @@ -667,7 +667,8 @@ def get_fees(event, request, total, invoice_address, provider): tax_rule=payment_fee_tax_rule )) - for recv, resp in fee_calculation_for_cart.send(sender=event, request=request, invoice_address=invoice_address): + for recv, resp in fee_calculation_for_cart.send(sender=event, request=request, invoice_address=invoice_address, + total=total): fees += resp return fees diff --git a/src/pretix/base/services/orders.py b/src/pretix/base/services/orders.py index 8d77c38c7..129d23c2b 100644 --- a/src/pretix/base/services/orders.py +++ b/src/pretix/base/services/orders.py @@ -439,8 +439,8 @@ def _get_fees(positions: List[CartPosition], payment_provider: BasePaymentProvid fees.append(OrderFee(fee_type=OrderFee.FEE_TYPE_PAYMENT, value=payment_fee, internal_type=payment_provider.identifier)) - for recv, resp in order_fee_calculation.send(sender=event, invoice_address=address, - meta_info=meta_info, posiitons=positions): + for recv, resp in order_fee_calculation.send(sender=event, invoice_address=address, total=total, + meta_info=meta_info, positions=positions): fees += resp return fees diff --git a/src/pretix/base/signals.py b/src/pretix/base/signals.py index 7f4bfea13..bfc51d898 100644 --- a/src/pretix/base/signals.py +++ b/src/pretix/base/signals.py @@ -291,7 +291,7 @@ an OrderedDict of (setting name, form field). """ order_fee_calculation = EventPluginSignal( - providing_args=['request'] + providing_args=['positions', 'invoice_address', 'meta_info', 'total'] ) """ This signals allows you to add fees to an order while it is being created. You are expected to @@ -300,7 +300,9 @@ return a list of ``OrderFee`` objects that are not yet saved to the database As with all plugin signals, the ``sender`` keyword argument will contain the event. A ``positions`` argument will contain the cart positions and ``invoice_address`` the invoice address (useful for -tax calculation). The argument ``meta_info`` contains the order's meta dictionary. +tax calculation). The argument ``meta_info`` contains the order's meta dictionary. The ``total`` +keyword argument will contain the total cart sum without any fees. You should not rely on this +``total`` value for fee calculations as other fees might interfere. """ order_fee_type_name = EventPluginSignal( diff --git a/src/pretix/presale/signals.py b/src/pretix/presale/signals.py index cef3b7f71..09f21915d 100644 --- a/src/pretix/presale/signals.py +++ b/src/pretix/presale/signals.py @@ -80,7 +80,7 @@ argument will contain the request object. """ fee_calculation_for_cart = EventPluginSignal( - providing_args=['request'] + providing_args=['request', 'invoice_address', 'total'] ) """ This signals allows you to add fees to a cart. You are expected to return a list of ``OrderFee`` @@ -88,7 +88,8 @@ objects that are not yet saved to the database (because there is no order yet). As with all plugin signals, the ``sender`` keyword argument will contain the event. A ``request`` argument will contain the request object and ``invoice_address`` the invoice address (useful for -tax calculation). +tax calculation). The ``total`` keyword argument will contain the total cart sum without any fees. +You should not rely on this ``total`` value for fee calculations as other fees might interfere. """ contact_form_fields = EventPluginSignal(