diff --git a/nummi/main/static/main/css/main.css b/nummi/main/static/main/css/main.css index f06189f..33a6c0c 100644 --- a/nummi/main/static/main/css/main.css +++ b/nummi/main/static/main/css/main.css @@ -336,6 +336,7 @@ ul.messages { .accounts { display: grid; grid-row-gap: 0.5rem; + grid-auto-rows: min-content; dl { margin: 0; diff --git a/nummi/main/templates/main/index.html b/nummi/main/templates/main/index.html index 01006f1..484c51a 100644 --- a/nummi/main/templates/main/index.html +++ b/nummi/main/templates/main/index.html @@ -30,18 +30,22 @@ {% translate "Create account" %} -
-

{% translate "Categories" %}

- {% spaceless %} -

- {% for cat in categories %} - {{ cat.icon|remix }}{{ cat }} - {% endfor %} - {{ "add"|remix }}{% translate "Create category" %} -

- {% endspaceless %} +
+

{% translate "Statements" %}

+ {% include "statement/statement_table.html" %}
+
+

{% translate "Categories" %}

+ {% spaceless %} +

+ {% for cat in categories %} + {{ cat.icon|remix }}{{ cat }} + {% endfor %} + {{ "add"|remix }}{% translate "Create category" %} +

+ {% endspaceless %} +
{% if history %}

{% translate "History" %}

diff --git a/nummi/main/views.py b/nummi/main/views.py index 72e6840..2786ed9 100644 --- a/nummi/main/views.py +++ b/nummi/main/views.py @@ -25,20 +25,23 @@ class IndexView(LoginRequiredMixin, TemplateView): def get_context_data(self, **kwargs): _max = 8 _transactions = Transaction.objects.filter(user=self.request.user) - _statements = Statement.objects.filter(user=self.request.user) _accounts = Account.objects.filter(user=self.request.user) + _statements = ( + Statement.objects.filter(user=self.request.user) + .exclude(account__archived=True) + .order_by("account__id", "-date") + .distinct("account__id") + ) res = { "accounts": _accounts, - "transactions": _transactions[:_max], "categories": Category.objects.filter(user=self.request.user), - "statements": _statements[:_max], + "statements": _statements, "history": history(_transactions.exclude(category__budget=False)), } if _transactions.count() > _max: res["transactions_url"] = reverse_lazy("transactions") - if _statements.count() > _max: - res["statements_url"] = reverse_lazy("statements") + res["statements_url"] = reverse_lazy("statements") return super().get_context_data(**kwargs) | res