mirror of
https://github.com/pretix/pretix.git
synced 2026-05-07 15:34:02 +00:00
Fix crash if a tax rule on a fee prevents sale (PRETIXEU-8MZ)
This commit is contained in:
@@ -1126,13 +1126,17 @@ class PaymentStep(CartMixin, TemplateFlowStep):
|
||||
def _total_order_value(self):
|
||||
cart = get_cart(self.request)
|
||||
total = get_cart_total(self.request)
|
||||
total += sum([
|
||||
f.value for f in get_fees(
|
||||
self.request.event, self.request, total, self.invoice_address,
|
||||
[p for p in self.cart_session.get('payments', []) if p.get('multi_use_supported')],
|
||||
cart,
|
||||
)
|
||||
])
|
||||
try:
|
||||
total += sum([
|
||||
f.value for f in get_fees(
|
||||
self.request.event, self.request, total, self.invoice_address,
|
||||
[p for p in self.cart_session.get('payments', []) if p.get('multi_use_supported')],
|
||||
cart,
|
||||
)
|
||||
])
|
||||
except TaxRule.SaleNotAllowed:
|
||||
# ignore for now, will fail on order creation
|
||||
pass
|
||||
return Decimal(total)
|
||||
|
||||
@cached_property
|
||||
@@ -1201,6 +1205,7 @@ class PaymentStep(CartMixin, TemplateFlowStep):
|
||||
cart = self.get_cart(payments=simulated_payments)
|
||||
else:
|
||||
cart = self.get_cart()
|
||||
|
||||
resp = pprov.checkout_prepare(
|
||||
request,
|
||||
cart,
|
||||
@@ -1283,8 +1288,12 @@ class PaymentStep(CartMixin, TemplateFlowStep):
|
||||
|
||||
cart = get_cart(self.request)
|
||||
total = get_cart_total(self.request)
|
||||
total += sum([f.value for f in get_fees(self.request.event, self.request, total, self.invoice_address,
|
||||
self.cart_session.get('payments', []), cart)])
|
||||
try:
|
||||
total += sum([f.value for f in get_fees(self.request.event, self.request, total, self.invoice_address,
|
||||
self.cart_session.get('payments', []), cart)])
|
||||
except TaxRule.SaleNotAllowed:
|
||||
# ignore for now, will fail on order creation
|
||||
pass
|
||||
selected = self.current_selected_payments(total, warn=warn, total_includes_payment_fees=True)
|
||||
if sum(p['payment_amount'] for p in selected) != total:
|
||||
if warn:
|
||||
|
||||
@@ -49,7 +49,7 @@ from django_scopes import scopes_disabled
|
||||
from pretix.base.i18n import language
|
||||
from pretix.base.models import (
|
||||
CartPosition, Customer, InvoiceAddress, ItemAddOn, Question,
|
||||
QuestionAnswer, QuestionOption,
|
||||
QuestionAnswer, QuestionOption, TaxRule,
|
||||
)
|
||||
from pretix.base.services.cart import get_fees
|
||||
from pretix.base.templatetags.money import money_filter
|
||||
@@ -198,11 +198,15 @@ class CartMixin:
|
||||
if order:
|
||||
fees = order.fees.all()
|
||||
elif positions:
|
||||
fees = get_fees(
|
||||
self.request.event, self.request, total, self.invoice_address,
|
||||
payments if payments is not None else self.cart_session.get('payments', []),
|
||||
cartpos
|
||||
)
|
||||
try:
|
||||
fees = get_fees(
|
||||
self.request.event, self.request, total, self.invoice_address,
|
||||
payments if payments is not None else self.cart_session.get('payments', []),
|
||||
cartpos
|
||||
)
|
||||
except TaxRule.SaleNotAllowed:
|
||||
# ignore for now, will fail on order creation
|
||||
fees = []
|
||||
else:
|
||||
fees = []
|
||||
|
||||
@@ -389,7 +393,11 @@ def get_cart_is_free(request):
|
||||
pos = get_cart(request)
|
||||
ia = get_cart_invoice_address(request)
|
||||
total = get_cart_total(request)
|
||||
fees = get_fees(request.event, request, total, ia, cs.get('payments', []), pos)
|
||||
try:
|
||||
fees = get_fees(request.event, request, total, ia, cs.get('payments', []), pos)
|
||||
except TaxRule.SaleNotAllowed:
|
||||
# ignore for now, will fail on order creation
|
||||
fees = []
|
||||
request._cart_free_cache = total + sum(f.value for f in fees) == Decimal('0.00')
|
||||
return request._cart_free_cache
|
||||
|
||||
|
||||
Reference in New Issue
Block a user