forked from CGM_Public/pretix_original
Fix failing orderlist export if orders with invalid payment provider identifiers exist (Z#23233440) (#6159)
* Fix orderlist export if orders with invalid payment provider identifiers exist (Z#23233440) * Performance: Move _get_all_payment_methods out of loop
This commit is contained in:
@@ -160,7 +160,7 @@ class OrderListExporter(MultiSheetListExporter):
|
|||||||
|
|
||||||
def _get_all_payment_methods(self, qs):
|
def _get_all_payment_methods(self, qs):
|
||||||
pps = dict(get_all_payment_providers())
|
pps = dict(get_all_payment_providers())
|
||||||
return sorted([(pp, pps[pp]) for pp in set(
|
return sorted([(pp, pps.get(pp, pp)) for pp in set(
|
||||||
OrderPayment.objects.exclude(provider='free').filter(order__event__in=self.events).values_list(
|
OrderPayment.objects.exclude(provider='free').filter(order__event__in=self.events).values_list(
|
||||||
'provider', flat=True
|
'provider', flat=True
|
||||||
).distinct()
|
).distinct()
|
||||||
@@ -330,6 +330,7 @@ class OrderListExporter(MultiSheetListExporter):
|
|||||||
taxsum=Sum('tax_value'), grosssum=Sum('value')
|
taxsum=Sum('tax_value'), grosssum=Sum('value')
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
payment_methods = None
|
||||||
if form_data.get('include_payment_amounts'):
|
if form_data.get('include_payment_amounts'):
|
||||||
payment_sum_cache = {
|
payment_sum_cache = {
|
||||||
(o['order__id'], o['provider']): o['grosssum'] for o in
|
(o['order__id'], o['provider']): o['grosssum'] for o in
|
||||||
@@ -347,6 +348,7 @@ class OrderListExporter(MultiSheetListExporter):
|
|||||||
grosssum=Sum('amount')
|
grosssum=Sum('amount')
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
payment_methods = self._get_all_payment_methods(qs)
|
||||||
sum_cache = {
|
sum_cache = {
|
||||||
(o['order__id'], o['tax_rate']): o for o in
|
(o['order__id'], o['tax_rate']): o for o in
|
||||||
OrderPosition.objects.values('tax_rate', 'order__id').order_by().annotate(
|
OrderPosition.objects.values('tax_rate', 'order__id').order_by().annotate(
|
||||||
@@ -434,7 +436,6 @@ class OrderListExporter(MultiSheetListExporter):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if form_data.get('include_payment_amounts'):
|
if form_data.get('include_payment_amounts'):
|
||||||
payment_methods = self._get_all_payment_methods(qs)
|
|
||||||
for id, vn in payment_methods:
|
for id, vn in payment_methods:
|
||||||
row.append(
|
row.append(
|
||||||
payment_sum_cache.get((order.id, id), Decimal('0.00')) -
|
payment_sum_cache.get((order.id, id), Decimal('0.00')) -
|
||||||
|
|||||||
Reference in New Issue
Block a user