From 996f6a9f18f8c16baf5c79f720c0c872e865f0bf Mon Sep 17 00:00:00 2001 From: "Edgar P. Burkhart" Date: Wed, 21 Dec 2022 09:38:17 +0100 Subject: [PATCH] Add visibility on invoices Add links to invoices on transaction tables Added invoices and has_invoice properties to transactions --- nummi/main/models.py | 8 ++++++++ nummi/main/static/main/css/table.css | 1 + nummi/main/templates/main/tag/transaction_table.html | 10 +++++++++- nummi/main/templates/main/transaction.html | 2 +- nummi/main/views.py | 2 -- 5 files changed, 19 insertions(+), 4 deletions(-) diff --git a/nummi/main/models.py b/nummi/main/models.py index 664cc09..7238625 100644 --- a/nummi/main/models.py +++ b/nummi/main/models.py @@ -59,6 +59,14 @@ class Transaction(models.Model): def __str__(self): return f"{self.date} – {self.name}" + @property + def invoices(self): + return Invoice.objects.filter(transaction=self) + + @property + def has_invoice(self): + return self.invoices.count() > 0 + class Meta: ordering = ["-date"] verbose_name = _("Transaction") diff --git a/nummi/main/static/main/css/table.css b/nummi/main/static/main/css/table.css index e649e9a..bfed8a7 100644 --- a/nummi/main/static/main/css/table.css +++ b/nummi/main/static/main/css/table.css @@ -11,6 +11,7 @@ .table.col4 {grid-template-columns: repeat(4, auto)} .table.col5 {grid-template-columns: repeat(5, auto)} .table.col6 {grid-template-columns: repeat(6, auto)} +.table.col1-6 {grid-template-columns: min-content repeat(6, auto)} .table > div { display: contents; diff --git a/nummi/main/templates/main/tag/transaction_table.html b/nummi/main/templates/main/tag/transaction_table.html index d4a0622..b27e993 100644 --- a/nummi/main/templates/main/tag/transaction_table.html +++ b/nummi/main/templates/main/tag/transaction_table.html @@ -1,8 +1,9 @@ {% load main_extras %} {% load i18n %} -
+
+ {% translate "Date" %} {% translate "Name" %} {% translate "Value" %} @@ -12,6 +13,13 @@
{% for trans in transactions %}
+ + {% for invoice in trans.invoices %} + + + + {% endfor %} + {{ trans.date|date:"Y-m-d" }} {{ trans.name }} {{ trans.value|pmvalue }} diff --git a/nummi/main/templates/main/transaction.html b/nummi/main/templates/main/transaction.html index b9666e8..bae7974 100644 --- a/nummi/main/templates/main/transaction.html +++ b/nummi/main/templates/main/transaction.html @@ -22,7 +22,7 @@

{% translate "Invoices" %}

- {% for inv in invoices %} + {% for inv in transaction.invoices %}