forked from CGM_Public/pretix_original
Fix error when marking an expired order as paid
This commit is contained in:
@@ -208,7 +208,7 @@ class Order(LockModel, LoggedModel):
|
||||
def pending_sum(self):
|
||||
total = self.total
|
||||
if self.status in (Order.STATUS_REFUNDED, Order.STATUS_CANCELED):
|
||||
total = 0
|
||||
total = Decimal('0.00')
|
||||
payment_sum = self.payments.filter(
|
||||
state__in=(OrderPayment.PAYMENT_STATE_CONFIRMED, OrderPayment.PAYMENT_STATE_REFUNDED)
|
||||
).aggregate(s=Sum('amount'))['s'] or Decimal('0.00')
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
from decimal import Decimal
|
||||
|
||||
from django import forms
|
||||
from django.conf import settings
|
||||
from django.core.exceptions import ValidationError
|
||||
@@ -86,7 +88,7 @@ class MarkPaidForm(ConfirmPaymentForm):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
change_decimal_field(self.fields['amount'], self.instance.event.currency)
|
||||
self.fields['amount'].initial = max(0, self.instance.pending_sum)
|
||||
self.fields['amount'].initial = max(Decimal('0.00'), self.instance.pending_sum)
|
||||
|
||||
|
||||
class ExporterForm(forms.Form):
|
||||
|
||||
@@ -19,6 +19,8 @@ class DecimalTextInput(TextInput):
|
||||
return None
|
||||
if isinstance(value, str):
|
||||
return value
|
||||
if not isinstance(value, Decimal):
|
||||
value = Decimal(value)
|
||||
return formats.localize_input(value.quantize(Decimal('1') / 10 ** self.places))
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user