mirror of
https://github.com/ae-utbm/sith.git
synced 2025-06-08 04:05:22 +00:00
refactored invoice view and template
This commit is contained in:
parent
95b4b0ba03
commit
6803294358
@ -27,7 +27,7 @@
|
|||||||
{% for i in sums %}
|
{% for i in sums %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ i['club__name'] }}</td>
|
<td>{{ i['club__name'] }}</td>
|
||||||
<td>{{ i['selling_sum'] }} €</td>
|
<td>{{"%.2f"|format(i['selling_sum'])}} €</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
@ -35,4 +35,3 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -46,30 +46,23 @@ class InvoiceCallView(CounterAdminTabsMixin, CounterAdminMixin, TemplateView):
|
|||||||
)
|
)
|
||||||
from django.db.models import Case, Sum, When
|
from django.db.models import Case, Sum, When
|
||||||
|
|
||||||
kwargs["sum_cb"] = sum(
|
kwargs["sum_cb"] = Refilling.objects.filter(
|
||||||
[
|
payment_method="CARD",
|
||||||
r.amount
|
is_validated=True,
|
||||||
for r in Refilling.objects.filter(
|
date__gte=start_date,
|
||||||
payment_method="CARD",
|
date__lte=end_date,
|
||||||
is_validated=True,
|
).aggregate(amount=Sum(F("amount"), default=0))["amount"]
|
||||||
date__gte=start_date,
|
|
||||||
date__lte=end_date,
|
kwargs["sum_cb"] += Selling.objects.filter(
|
||||||
)
|
payment_method="CARD",
|
||||||
]
|
is_validated=True,
|
||||||
)
|
date__gte=start_date,
|
||||||
kwargs["sum_cb"] += sum(
|
date__lte=end_date,
|
||||||
[
|
).aggregate(amount=Sum(F("quantity") * F("unit_price"), default=0))["amount"]
|
||||||
s.quantity * s.unit_price
|
|
||||||
for s in Selling.objects.filter(
|
|
||||||
payment_method="CARD",
|
|
||||||
is_validated=True,
|
|
||||||
date__gte=start_date,
|
|
||||||
date__lte=end_date,
|
|
||||||
)
|
|
||||||
]
|
|
||||||
)
|
|
||||||
kwargs["start_date"] = start_date
|
kwargs["start_date"] = start_date
|
||||||
kwargs["sums"] = (
|
|
||||||
|
kwargs["sums"] = list(
|
||||||
Selling.objects.values("club__name")
|
Selling.objects.values("club__name")
|
||||||
.annotate(
|
.annotate(
|
||||||
selling_sum=Sum(
|
selling_sum=Sum(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user