mirror of
https://github.com/pretix/pretix.git
synced 2026-09-14 16:24:43 +00:00
Allow to filter for partially paid orders
This commit is contained in:
@@ -334,7 +334,7 @@ class Order(LockModel, LoggedModel):
|
|||||||
refund_sum=refund_sum_sq,
|
refund_sum=refund_sum_sq,
|
||||||
)
|
)
|
||||||
qs = qs.annotate(
|
qs = qs.annotate(
|
||||||
payment_refund_sum=Coalesce(payment_sum_sq, 0) - Coalesce(refund_sum_sq, 0),
|
computed_payment_refund_sum=Coalesce(payment_sum_sq, 0) - Coalesce(refund_sum_sq, 0),
|
||||||
)
|
)
|
||||||
|
|
||||||
qs = qs.annotate(
|
qs = qs.annotate(
|
||||||
|
|||||||
@@ -150,8 +150,8 @@ class OrderFilterForm(FilterForm):
|
|||||||
(Order.STATUS_PENDING + Order.STATUS_PAID, _('Pending or paid')),
|
(Order.STATUS_PENDING + Order.STATUS_PAID, _('Pending or paid')),
|
||||||
)),
|
)),
|
||||||
(_('Cancellations'), (
|
(_('Cancellations'), (
|
||||||
(Order.STATUS_CANCELED, _('Canceled')),
|
(Order.STATUS_CANCELED, _('Canceled (fully)')),
|
||||||
('cp', _('Canceled (or with paid fee)')),
|
('cp', _('Canceled (fully or with paid fee)')),
|
||||||
('rc', _('Cancellation requested')),
|
('rc', _('Cancellation requested')),
|
||||||
)),
|
)),
|
||||||
(_('Payment process'), (
|
(_('Payment process'), (
|
||||||
@@ -159,7 +159,8 @@ class OrderFilterForm(FilterForm):
|
|||||||
(Order.STATUS_PENDING + Order.STATUS_EXPIRED, _('Pending or expired')),
|
(Order.STATUS_PENDING + Order.STATUS_EXPIRED, _('Pending or expired')),
|
||||||
('o', _('Pending (overdue)')),
|
('o', _('Pending (overdue)')),
|
||||||
('overpaid', _('Overpaid')),
|
('overpaid', _('Overpaid')),
|
||||||
('underpaid', _('Underpaid')),
|
('partially_paid', _('Partially paid')),
|
||||||
|
('underpaid', _('Underpaid (but confirmed)')),
|
||||||
('pendingpaid', _('Pending (but fully paid)')),
|
('pendingpaid', _('Pending (but fully paid)')),
|
||||||
)),
|
)),
|
||||||
(_('Approval process'), (
|
(_('Approval process'), (
|
||||||
@@ -245,6 +246,14 @@ class OrderFilterForm(FilterForm):
|
|||||||
Q(status__in=(Order.STATUS_EXPIRED, Order.STATUS_PENDING)) & Q(pending_sum_t__lte=0)
|
Q(status__in=(Order.STATUS_EXPIRED, Order.STATUS_PENDING)) & Q(pending_sum_t__lte=0)
|
||||||
& Q(require_approval=False)
|
& Q(require_approval=False)
|
||||||
)
|
)
|
||||||
|
elif s == 'partially_paid':
|
||||||
|
qs = Order.annotate_overpayments(qs, refunds=False, results=False, sums=True)
|
||||||
|
qs = qs.filter(
|
||||||
|
computed_payment_refund_sum__lt=F('total'),
|
||||||
|
computed_payment_refund_sum__gt=Decimal('0.00')
|
||||||
|
).exclude(
|
||||||
|
status=Order.STATUS_CANCELED
|
||||||
|
)
|
||||||
elif s == 'underpaid':
|
elif s == 'underpaid':
|
||||||
qs = Order.annotate_overpayments(qs, refunds=False, results=False, sums=True)
|
qs = Order.annotate_overpayments(qs, refunds=False, results=False, sums=True)
|
||||||
qs = qs.filter(
|
qs = qs.filter(
|
||||||
|
|||||||
@@ -162,11 +162,11 @@
|
|||||||
{% elif o.is_pending_with_full_payment %}
|
{% elif o.is_pending_with_full_payment %}
|
||||||
<span class="label label-danger">{% trans "FULLY PAID" %}</span>
|
<span class="label label-danger">{% trans "FULLY PAID" %}</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if o.payment_refund_sum == o.total or o.payment_refund_sum == 0 %}
|
{% if o.computed_payment_refund_sum == o.total or o.computed_payment_refund_sum == 0 %}
|
||||||
<span class="text-muted">
|
<span class="text-muted">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{{ o.payment_refund_sum|money:request.event.currency }} /
|
{{ o.computed_payment_refund_sum|money:request.event.currency }} /
|
||||||
{% if o.payment_refund_sum == o.total or o.payment_refund_sum == 0 %}
|
{% if o.computed_payment_refund_sum == o.total or o.computed_payment_refund_sum == 0 %}
|
||||||
</span>
|
</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{{ o.total|money:request.event.currency }}
|
{{ o.total|money:request.event.currency }}
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ class OrderList(OrderSearchMixin, EventPermissionRequiredMixin, PaginationMixin,
|
|||||||
has_cancellation_request=Exists(CancellationRequest.objects.filter(order=OuterRef('pk')))
|
has_cancellation_request=Exists(CancellationRequest.objects.filter(order=OuterRef('pk')))
|
||||||
).values(
|
).values(
|
||||||
'pk', 'pcnt', 'is_overpaid', 'is_underpaid', 'is_pending_with_full_payment', 'has_external_refund',
|
'pk', 'pcnt', 'is_overpaid', 'is_underpaid', 'is_pending_with_full_payment', 'has_external_refund',
|
||||||
'has_pending_refund', 'has_cancellation_request'
|
'has_pending_refund', 'has_cancellation_request', 'computed_payment_refund_sum'
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,6 +175,7 @@ class OrderList(OrderSearchMixin, EventPermissionRequiredMixin, PaginationMixin,
|
|||||||
o.has_external_refund = annotated.get(o.pk)['has_external_refund']
|
o.has_external_refund = annotated.get(o.pk)['has_external_refund']
|
||||||
o.has_pending_refund = annotated.get(o.pk)['has_pending_refund']
|
o.has_pending_refund = annotated.get(o.pk)['has_pending_refund']
|
||||||
o.has_cancellation_request = annotated.get(o.pk)['has_cancellation_request']
|
o.has_cancellation_request = annotated.get(o.pk)['has_cancellation_request']
|
||||||
|
o.computed_payment_refund_sum = annotated.get(o.pk)['computed_payment_refund_sum']
|
||||||
o.sales_channel_obj = scs[o.sales_channel]
|
o.sales_channel_obj = scs[o.sales_channel]
|
||||||
|
|
||||||
if ctx['page_obj'].paginator.count < 1000:
|
if ctx['page_obj'].paginator.count < 1000:
|
||||||
|
|||||||
Reference in New Issue
Block a user