mirror of
https://github.com/pretix/pretix-servicefees.git
synced 2024-11-23 22:50:21 +01:00
Support for https://github.com/pretix/pretix/pull/2912 (#26)
This commit is contained in:
parent
0f7476a5d3
commit
97fa4b2bfc
1 changed files with 23 additions and 15 deletions
|
@ -31,7 +31,7 @@ def navbar_settings(sender, request, **kwargs):
|
||||||
}]
|
}]
|
||||||
|
|
||||||
|
|
||||||
def get_fees(event, total, invoice_address, mod='', request=None, positions=[], gift_cards=None):
|
def get_fees(event, total, invoice_address, mod='', request=None, positions=[], gift_cards=None, payment_requests=None):
|
||||||
if request is not None and not positions:
|
if request is not None and not positions:
|
||||||
positions = get_cart(request)
|
positions = get_cart(request)
|
||||||
|
|
||||||
|
@ -64,6 +64,13 @@ def get_fees(event, total, invoice_address, mod='', request=None, positions=[],
|
||||||
fee_percent = Decimal("0") if fee_percent is None else fee_percent
|
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):
|
if event.settings.get('service_fee_skip_if_gift_card', as_type=bool):
|
||||||
|
if payment_requests is not None:
|
||||||
|
for p in payment_requests:
|
||||||
|
if p['provider'] == 'giftcard':
|
||||||
|
total = max(0, total - Decimal(p['max_value'] or '0'))
|
||||||
|
|
||||||
|
else:
|
||||||
|
# pretix pre 4.15
|
||||||
gift_cards = gift_cards or []
|
gift_cards = gift_cards or []
|
||||||
if request:
|
if request:
|
||||||
cs = cart_session(request)
|
cs = cart_session(request)
|
||||||
|
@ -146,7 +153,7 @@ def cart_fee(sender: Event, request: HttpRequest, invoice_address, total, **kwar
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
mod = '_resellers'
|
mod = '_resellers'
|
||||||
return get_fees(sender, total, invoice_address, mod, request)
|
return get_fees(sender, total, invoice_address, mod, request, payment_requests=kwargs.get('payment_requests'))
|
||||||
|
|
||||||
|
|
||||||
@receiver(order_fee_calculation, dispatch_uid="service_fee_calc_order")
|
@receiver(order_fee_calculation, dispatch_uid="service_fee_calc_order")
|
||||||
|
@ -164,7 +171,8 @@ def order_fee(sender: Event, positions, invoice_address, total, meta_info, gift_
|
||||||
if config.skip_default_service_fees:
|
if config.skip_default_service_fees:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
return get_fees(sender, total, invoice_address, mod, positions=positions, gift_cards=gift_cards)
|
return get_fees(sender, total, invoice_address, mod, positions=positions, gift_cards=gift_cards,
|
||||||
|
payment_requests=kwargs.get('payment_requests'))
|
||||||
|
|
||||||
|
|
||||||
@receiver(front_page_top, dispatch_uid="service_fee_front_page_top")
|
@receiver(front_page_top, dispatch_uid="service_fee_front_page_top")
|
||||||
|
|
Loading…
Reference in a new issue