mirror of
https://github.com/pretix/pretix.git
synced 2026-05-11 16:13:59 +00:00
Improve visual transaction table
This commit is contained in:
@@ -2515,6 +2515,14 @@ class Transaction(models.Model):
|
|||||||
obj.tax_rule_id, obj.tax_value, obj.fee_type, obj.internal_type)
|
obj.tax_rule_id, obj.tax_value, obj.fee_type, obj.internal_type)
|
||||||
raise ValueError('invalid state') # noqa
|
raise ValueError('invalid state') # noqa
|
||||||
|
|
||||||
|
@property
|
||||||
|
def full_price(self):
|
||||||
|
return self.price * self.count
|
||||||
|
|
||||||
|
@property
|
||||||
|
def full_tax_value(self):
|
||||||
|
return self.tax_value * self.count
|
||||||
|
|
||||||
|
|
||||||
class CartPosition(AbstractPosition):
|
class CartPosition(AbstractPosition):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -18,10 +18,11 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th>{% trans "Date" %}</th>
|
<th>{% trans "Date" %}</th>
|
||||||
<th>{% trans "Product" %}</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 rate" %}</th>
|
||||||
<th class="text-right flip">{% trans "Tax value" %}</th>
|
<th class="text-right flip">{% trans "Quantity" %}</th>
|
||||||
<th class="text-right flip">{% trans "Price" %}</th>
|
<th class="text-right flip">{% trans "Single price" %}</th>
|
||||||
|
<th class="text-right flip">{% trans "Total tax value" %}</th>
|
||||||
|
<th class="text-right flip">{% trans "Total price" %}</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@@ -50,12 +51,31 @@
|
|||||||
<br>{{ t.subevent }}
|
<br>{{ t.subevent }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
<td class="text-right flip">{{ t.count }} ×</td>
|
|
||||||
<td class="text-right flip">{{ t.tax_rate }} %</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.count }} ×</td>
|
||||||
<td class="text-right flip">{{ t.price|money:request.event.currency }}</td>
|
<td class="text-right flip">{{ t.price|money:request.event.currency }}</td>
|
||||||
|
<td class="text-right flip">{{ t.full_tax_value|money:request.event.currency }}</td>
|
||||||
|
<td class="text-right flip">{{ t.full_price|money:request.event.currency }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
<tfoot>
|
||||||
|
<tr class="{% if t.count < 0 %}text-danger{% endif %}">
|
||||||
|
<td>
|
||||||
|
<strong>{% trans "Sum" %}</strong>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td></td>
|
||||||
|
<td class="text-right flip">
|
||||||
|
<strong>
|
||||||
|
{{ sums.count }}
|
||||||
|
</strong>
|
||||||
|
</td>
|
||||||
|
<td></td>
|
||||||
|
<td class="text-right flip"><strong>{{ sums.full_tax_value|money:request.event.currency }}</strong></td>
|
||||||
|
<td class="text-right flip"><strong>{{ sums.full_price|money:request.event.currency }}</strong></td>
|
||||||
|
</tr>
|
||||||
|
</tfoot>
|
||||||
</table>
|
</table>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ from django.core.exceptions import ValidationError
|
|||||||
from django.core.files import File
|
from django.core.files import File
|
||||||
from django.db import transaction
|
from django.db import transaction
|
||||||
from django.db.models import (
|
from django.db.models import (
|
||||||
Count, Exists, IntegerField, OuterRef, Prefetch, ProtectedError, Q,
|
Count, Exists, F, IntegerField, OuterRef, Prefetch, ProtectedError, Q,
|
||||||
Subquery, Sum,
|
Subquery, Sum,
|
||||||
)
|
)
|
||||||
from django.forms import formset_factory
|
from django.forms import formset_factory
|
||||||
@@ -410,6 +410,11 @@ class OrderTransactions(OrderView):
|
|||||||
ctx['transactions'] = self.order.transactions.select_related(
|
ctx['transactions'] = self.order.transactions.select_related(
|
||||||
'item', 'variation', 'subevent'
|
'item', 'variation', 'subevent'
|
||||||
).order_by('datetime')
|
).order_by('datetime')
|
||||||
|
ctx['sums'] = self.order.transactions.aggregate(
|
||||||
|
count=Sum('count'),
|
||||||
|
full_price=Sum(F('count') * F('price')),
|
||||||
|
full_tax_value=Sum(F('count') * F('tax_value')),
|
||||||
|
)
|
||||||
return ctx
|
return ctx
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user