mirror of
https://github.com/pretix/pretix-servicefees.git
synced 2024-12-25 04:23:08 +01:00
Allow to drop fees if paid with gift card
This commit is contained in:
parent
d1eea4e240
commit
b142e1d433
3 changed files with 22 additions and 0 deletions
|
@ -12,6 +12,7 @@ from pretix.base.templatetags.money import money_filter
|
|||
from pretix.control.signals import nav_event_settings
|
||||
from pretix.presale.signals import fee_calculation_for_cart, front_page_top, order_meta_from_request
|
||||
from pretix.presale.views import get_cart
|
||||
from pretix.presale.views.cart import cart_session
|
||||
|
||||
|
||||
@receiver(nav_event_settings, dispatch_uid='service_fee_nav_settings')
|
||||
|
@ -48,6 +49,18 @@ def get_fees(event, total, invoice_address, mod='', request=None, positions=[]):
|
|||
fee_abs = Decimal("0") if fee_abs is None else fee_abs
|
||||
fee_percent = Decimal("0") if fee_percent is None else fee_percent
|
||||
|
||||
if event.settings.get('service_fee_skip_if_gift_card', as_type=bool):
|
||||
cs = cart_session(request)
|
||||
if cs.get('gift_cards'):
|
||||
gc_qs = event.organizer.accepted_gift_cards.filter(pk__in=cs.get('gift_cards'), currency=event.currency)
|
||||
summed = 0
|
||||
for gc in gc_qs:
|
||||
fval = Decimal(gc.value) # TODO: don't require an extra query
|
||||
fval = min(fval, total - summed)
|
||||
if fval > 0:
|
||||
total -= fval
|
||||
summed += fval
|
||||
|
||||
if (fee_per_ticket or fee_abs or fee_percent) and total != Decimal('0.00'):
|
||||
fee = round_decimal(fee_abs + total * (fee_percent / 100) + len(positions) * fee_per_ticket, event.currency)
|
||||
tax_rule = event.settings.tax_rate_default or TaxRule.zero()
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
{% bootstrap_field form.service_fee_per_ticket addon_after=request.event.currency 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" %}
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>{% trans "Service fees with resellers" %}</legend>
|
||||
|
|
|
@ -25,6 +25,14 @@ class ServiceFeeSettingsForm(SettingsForm):
|
|||
help_text=_('This fee will be added for each ticket sold, except for free items and addons.'),
|
||||
required=False
|
||||
)
|
||||
service_fee_skip_if_gift_card = forms.BooleanField(
|
||||
label=_('Do not charge service fee on tickets paid with gift cards'),
|
||||
help_text=_('If a gift card is used for the payment, the percentual fees will be applied on the value of the '
|
||||
'tickets minus the value of the gift cards. All fixed fees will be dropped if the tickets can '
|
||||
'be paid with gift cards entirely. This only works if the gift card is redeemd when the order is '
|
||||
'submitted, not if it\'s used to pay an unpaid order later.'),
|
||||
required=False
|
||||
)
|
||||
|
||||
service_fee_abs_resellers = forms.DecimalField(
|
||||
label=_('Fixed fee per order'),
|
||||
|
|
Loading…
Reference in a new issue