From d19d23fe37cb8029efe3f0179c01939471996105 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 08:59:48 +0800 Subject: [PATCH] Replaced the "transaction" property with the "url" property in the ReportEntry model of ledger, so that the report entry does not need to keep the transaction object. --- src/accounting/report/reports/ledger.py | 7 ++++--- src/accounting/templates/accounting/report/ledger.html | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/accounting/report/reports/ledger.py b/src/accounting/report/reports/ledger.py index 37bd6e7..ce208c2 100644 --- a/src/accounting/report/reports/ledger.py +++ b/src/accounting/report/reports/ledger.py @@ -46,8 +46,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 @@ -64,13 +62,16 @@ 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.summary = entry.summary self.debit = entry.amount if entry.is_debit else None self.credit = None if entry.is_debit else entry.amount 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/ledger.html b/src/accounting/templates/accounting/report/ledger.html index b701e40..d931956 100644 --- a/src/accounting/templates/accounting/report/ledger.html +++ b/src/accounting/templates/accounting/report/ledger.html @@ -79,7 +79,7 @@ First written: 2023/3/5 {% endwith %} {% endif %} {% for entry in report.entries %} - + {% include "accounting/report/include/ledger-row-desktop.html" %} {% endfor %} @@ -107,7 +107,7 @@ First written: 2023/3/5 {% endwith %} {% endif %} {% for entry in report.entries %} - + {% include "accounting/report/include/ledger-row-mobile.html" %} {% endfor %}