diff --git a/nummi/account/templates/account/account_detail.html b/nummi/account/templates/account/account_detail.html
index 5b7fa17..6d7e408 100644
--- a/nummi/account/templates/account/account_detail.html
+++ b/nummi/account/templates/account/account_detail.html
@@ -22,6 +22,6 @@
{% translate "History" %}
- {% history_plot account.transactions %}
+ {% history_plot account.transactions account=account %}
{% endblock body %}
diff --git a/nummi/category/templates/category/category_detail.html b/nummi/category/templates/category/category_detail.html
index 3c13cbb..02b9635 100644
--- a/nummi/category/templates/category/category_detail.html
+++ b/nummi/category/templates/category/category_detail.html
@@ -20,6 +20,6 @@
{% translate "History" %}
- {% history_plot category.transaction_set.all %}
+ {% history_plot category.transaction_set category=category %}
{% endblock body %}
diff --git a/nummi/history/templatetags/history_extras.py b/nummi/history/templatetags/history_extras.py
index 7d278f6..e8f940b 100644
--- a/nummi/history/templatetags/history_extras.py
+++ b/nummi/history/templatetags/history_extras.py
@@ -10,9 +10,13 @@ register = template.Library()
@register.inclusion_tag("history/plot.html")
def history_plot(transactions, **kwargs):
- return kwargs | {
- "history": history(transactions.exclude(category__budget=False)),
- }
+ options = kwargs
+ 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
diff --git a/nummi/transaction/views.py b/nummi/transaction/views.py
index 90e681d..c3f854f 100644
--- a/nummi/transaction/views.py
+++ b/nummi/transaction/views.py
@@ -136,7 +136,7 @@ class TransactionACMixin:
Account.objects.filter(user=self.request.user),
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:
self.category = get_object_or_404(
Category.objects.filter(user=self.request.user),