Fix urls in category plot on month page

This commit is contained in:
Edgar P. Burkhart 2023-05-03 12:20:19 +02:00
parent 574d1d2875
commit eabdaf2516
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227
2 changed files with 13 additions and 9 deletions

View file

@ -6,7 +6,7 @@ register = template.Library()
@register.inclusion_tag("category/category_plot.html")
def category_plot(transactions):
def category_plot(transactions, **kwargs):
categories = (
transactions.filter(category__budget=True)
.values("category", "category__name", "category__icon")
@ -17,11 +17,15 @@ def category_plot(transactions):
)
.order_by("-sum")
)
return {
"categories": categories,
} | categories.aggregate(
max=Greatest(models.Sum("sum_m"), models.Sum("sum_p")),
total_m=models.Sum("sum_m"),
total_p=models.Sum("sum_p"),
total=models.Sum("value"),
return (
kwargs
| {
"categories": categories,
}
| categories.aggregate(
max=Greatest(models.Sum("sum_m"), models.Sum("sum_p")),
total_m=models.Sum("sum_m"),
total_p=models.Sum("sum_p"),
total=models.Sum("value"),
)
)

View file

@ -12,6 +12,6 @@
{{ block.super }}
{% if not category %}
<h3>{% translate "Categories" %}</h3>
{% category_plot transactions %}
{% category_plot transactions month=month %}
{% endif %}
{% endblock %}