Fix history plot

Fix #31
This commit is contained in:
Edgar P. Burkhart 2025-01-03 14:55:16 +01:00
parent c14e075cad
commit 5b49836bad
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227
4 changed files with 10 additions and 6 deletions

View file

@ -22,6 +22,6 @@
</section> </section>
<section> <section>
<h3>{% translate "History" %}</h3> <h3>{% translate "History" %}</h3>
{% history_plot account.transactions %} {% history_plot account.transactions account=account %}
</section> </section>
{% endblock body %} {% endblock body %}

View file

@ -20,6 +20,6 @@
</section> </section>
<section> <section>
<h3>{% translate "History" %}</h3> <h3>{% translate "History" %}</h3>
{% history_plot category.transaction_set.all %} {% history_plot category.transaction_set category=category %}
</section> </section>
{% endblock body %} {% endblock body %}

View file

@ -10,9 +10,13 @@ register = template.Library()
@register.inclusion_tag("history/plot.html") @register.inclusion_tag("history/plot.html")
def history_plot(transactions, **kwargs): def history_plot(transactions, **kwargs):
return kwargs | { options = kwargs
"history": history(transactions.exclude(category__budget=False)), if "category" in kwargs or "account" in kwargs:
} options["history"] = history(transactions.all())
else:
options["history"] = history(transactions.exclude(category__budget=False))
return options
@register.simple_tag @register.simple_tag

View file

@ -136,7 +136,7 @@ class TransactionACMixin:
Account.objects.filter(user=self.request.user), Account.objects.filter(user=self.request.user),
pk=self.kwargs["account"], pk=self.kwargs["account"],
) )
return super().get_queryset().filter(account=self.account) return super().get_queryset().filter(statement__account=self.account)
if "category" in self.kwargs: if "category" in self.kwargs:
self.category = get_object_or_404( self.category = get_object_or_404(
Category.objects.filter(user=self.request.user), Category.objects.filter(user=self.request.user),