diff --git a/nummi/category/templates/category/category_plot.html b/nummi/category/templates/category/category_plot.html
index 1313da6..33d67fd 100644
--- a/nummi/category/templates/category/category_plot.html
+++ b/nummi/category/templates/category/category_plot.html
@@ -58,5 +58,30 @@
{% endfor %}
{% endspaceless %}
+ {% if categories %}
+
+
+ {% translate "Total" %} |
+ {{ total_m|pmrvalue }} |
+
+
+ {% if total < 0 %}
+
+ {{ total|pmrvalue }}
+
+ {% endif %}
+ |
+
+
+ {% if total > 0 %}
+
+ {{ total|pmrvalue }}
+
+ {% endif %}
+ |
+ {{ total_p|pmrvalue }} |
+
+
+ {% endif %}
diff --git a/nummi/category/templatetags/category.py b/nummi/category/templatetags/category.py
index c43256b..5709af0 100644
--- a/nummi/category/templatetags/category.py
+++ b/nummi/category/templatetags/category.py
@@ -1,5 +1,6 @@
from django import template
from django.db import models
+from django.db.models.functions import Greatest
register = template.Library()
@@ -18,10 +19,9 @@ def category_plot(transactions):
)
return {
"categories": categories,
- "max": max(
- categories.aggregate(
- max=models.Max("sum_p", default=0),
- min=models.Min("sum_m", default=0),
- ).values(),
- ),
- }
+ } | 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"),
+ )
diff --git a/nummi/main/static/main/css/plot.css b/nummi/main/static/main/css/plot.css
index d38d575..15fc7ab 100644
--- a/nummi/main/static/main/css/plot.css
+++ b/nummi/main/static/main/css/plot.css
@@ -70,3 +70,7 @@ table.full-width col.bar {
overflow: hidden;
}
}
+
+.plot tfoot {
+ background: var(--bg-01);
+}