From 74eee034d0c02973642a8f9111da93267fa6e32c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=9D=E7=91=AA=E8=B2=93?= Date: Thu, 9 Mar 2023 09:01:15 +0800 Subject: [PATCH] Replaced the "transaction" property with the "url" property in the ReportEntry model of the income and expenses log, so that the report entry does not need to keep the transaction object. --- src/accounting/report/reports/income_expenses.py | 7 ++++--- .../templates/accounting/report/income-expenses.html | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/accounting/report/reports/income_expenses.py b/src/accounting/report/reports/income_expenses.py index f5ba3b0..04586fe 100644 --- a/src/accounting/report/reports/income_expenses.py +++ b/src/accounting/report/reports/income_expenses.py @@ -47,8 +47,6 @@ class ReportEntry: :param entry: The journal entry. """ - self.transaction: Transaction | None = None - """The transaction.""" self.is_brought_forward: bool = False """Whether this is the brought-forward entry.""" self.is_total: bool = False @@ -67,14 +65,17 @@ class ReportEntry: """The balance.""" self.note: str | None = None """The note.""" + self.url: str | None = None + """The URL to the journal entry.""" if entry is not None: - self.transaction = entry.transaction self.date = entry.transaction.date self.account = entry.account self.summary = entry.summary self.income = None if entry.is_debit else entry.amount self.expense = entry.amount if entry.is_debit else None self.note = entry.transaction.note + self.url = url_for("accounting.transaction.detail", + txn=entry.transaction) class EntryCollector: diff --git a/src/accounting/templates/accounting/report/income-expenses.html b/src/accounting/templates/accounting/report/income-expenses.html index 1ff85b1..6e5a1f9 100644 --- a/src/accounting/templates/accounting/report/income-expenses.html +++ b/src/accounting/templates/accounting/report/income-expenses.html @@ -80,7 +80,7 @@ First written: 2023/3/5 {% endwith %} {% endif %} {% for entry in report.entries %} - + {% include "accounting/report/include/income-expenses-row-desktop.html" %} {% endfor %} @@ -108,7 +108,7 @@ First written: 2023/3/5 {% endwith %} {% endif %} {% for entry in report.entries %} - + {% include "accounting/report/include/income-expenses-row-mobile.html" %} {% endfor %}