Data model for transactional history (#2147)

This commit is contained in:
Raphael Michel
2021-10-18 17:28:58 +02:00
committed by GitHub
parent c4e71011ee
commit 8ebba9de86
19 changed files with 699 additions and 10 deletions

View File

@@ -52,18 +52,22 @@
{% if order.status == 'n' or order.status == 'e' %}
<a href="{% url "control:event.order.transition" event=request.event.slug organizer=request.event.organizer.slug code=order.code %}?status=p"
class="btn {% if overpaid >= 0 %}btn-success{% else %}btn-default{% endif %}">
<span class="fa fa-check"></span>
{% trans "Mark as paid" %}
</a>
<a href="{% url "control:event.order.extend" event=request.event.slug organizer=request.event.organizer.slug code=order.code %}" class="btn btn-default">
<span class="fa fa-clock-o"></span>
{% trans "Extend payment term" %}
</a>
{% endif %}
{% if order.cancel_allowed %}
<a href="{% url "control:event.order.transition" event=request.event.slug organizer=request.event.organizer.slug code=order.code %}?status=c" class="btn btn-default">
<span class="fa fa-ban"></span>
{% trans "Cancel order" %}
</a>
{% elif order.status == 'c' %}
<a href="{% url "control:event.order.reactivate" event=request.event.slug organizer=request.event.organizer.slug code=order.code %}" class="btn btn-default">
<span class="fa fa-reply"></span>
{% trans "Reactivate order" %}
</a>
{% endif %}
@@ -71,11 +75,17 @@
<a href="{% eventurl request.event "presale:event.order" order=order.code secret=order.secret %}"
class="btn btn-default" target="_blank">
<span class="fa fa-eye"></span>
{% trans "View order as user" %}
</a>
<a href="{% url "control:event.order.mail_history" event=request.event.slug organizer=request.event.organizer.slug code=order.code %}" class="btn btn-default">
<span class="fa fa-envelope-o"></span>
{% trans "View email history" %}
</a>
<a href="{% url "control:event.order.transactions" event=request.event.slug organizer=request.event.organizer.slug code=order.code %}" class="btn btn-default">
<span class="fa fa-list"></span>
{% trans "View transaction history" %}
</a>
</div>
</div>
</form>

View File

@@ -0,0 +1,61 @@
{% extends "pretixcontrol/event/base.html" %}
{% load i18n %}
{% load bootstrap3 %}
{% load money %}
{% block title %}{% trans "Transaction history" %}{% endblock %}
{% block content %}
<h1>
{% trans "Transaction history" %}
<a class="btn btn-link btn-lg"
href="{% url "control:event.order" event=request.event.slug organizer=request.event.organizer.slug code=order.code %}">
{% blocktrans trimmed with order=order.code %}
Back to order {{ order }}
{% endblocktrans %}
</a>
</h1>
<table class="table table-condensed table-hover">
<thead>
<tr>
<th>{% trans "Date" %}</th>
<th>{% trans "Product" %}</th>
<th class="text-right flip">{% trans "Quantity" %}</th>
<th class="text-right flip">{% trans "Tax rate" %}</th>
<th class="text-right flip">{% trans "Tax value" %}</th>
<th class="text-right flip">{% trans "Price" %}</th>
</tr>
</thead>
<tbody>
{% for t in transactions %}
<tr class="{% if t.count < 0 %}text-danger{% endif %}">
<td>
{{ t.datetime|date:"SHORT_DATETIME_FORMAT" }}
{% if t.migrated %}
<span class="fa fa-warning text-warning"
data-toggle="tooltip"
title="{% trans 'This order was created before we introduced this table, therefore this data might be inaccurate.' %}"
></span>
{% endif %}
</td>
<td>
{% if t.item %}
{{ t.item }}
{% if t.variation %}
{{ t.variation }}
{% endif %}
{% endif %}
{% if t.fee_type %}
{{ t.get_fee_type_display }}
{% endif %}
{% if t.subevent %}
<br>{{ t.subevent }}
{% endif %}
</td>
<td class="text-right flip">{{ t.count }} &times;</td>
<td class="text-right flip">{{ t.tax_rate }} %</td>
<td class="text-right flip">{{ t.tax_value|money:request.event.currency }}</td>
<td class="text-right flip">{{ t.price|money:request.event.currency }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endblock %}

View File

@@ -345,6 +345,7 @@ urlpatterns = [
re_path(r'^orders/(?P<code>[0-9A-Z]+)/cancellationrequests/(?P<req>\d+)/delete$',
orders.OrderCancellationRequestDelete.as_view(),
name='event.order.cancellationrequests.delete'),
re_path(r'^orders/(?P<code>[0-9A-Z]+)/transactions/$', orders.OrderTransactions.as_view(), name='event.order.transactions'),
re_path(r'^orders/(?P<code>[0-9A-Z]+)/$', orders.OrderDetail.as_view(), name='event.order'),
re_path(r'^invoice/(?P<invoice>[^/]+)$', orders.InvoiceDownload.as_view(),
name='event.invoice.download'),

View File

@@ -401,6 +401,18 @@ class OrderDetail(OrderView):
}
class OrderTransactions(OrderView):
template_name = 'pretixcontrol/order/transactions.html'
permission = 'can_view_orders'
def get_context_data(self, **kwargs):
ctx = super().get_context_data(**kwargs)
ctx['transactions'] = self.order.transactions.select_related(
'item', 'variation', 'subevent'
).order_by('datetime')
return ctx
class OrderDownload(AsyncAction, OrderView):
task = generate
permission = 'can_view_orders'