From 9833bac6e462f06cfd3775ceb3ee9ac67c862475 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=9D=E7=91=AA=E8=B2=93?= Date: Sat, 4 Mar 2023 19:30:04 +0800 Subject: [PATCH] Added the TransactionTypeEnum in the new "accounting.utils.txn_types" module to remove the dependency from the "accounting.report" module to the "accounting.transaction" module. --- src/accounting/report/reports.py | 7 +- .../include/add-txn-material-fab.html | 6 +- .../templates/accounting/report/journal.html | 8 +-- .../accounting/transaction/list.html | 6 +- src/accounting/transaction/converters.py | 13 ++-- src/accounting/transaction/dispatcher.py | 64 +++++++------------ src/accounting/transaction/views.py | 39 +++++------ src/accounting/utils/txn_types.py | 30 +++++++++ 8 files changed, 94 insertions(+), 79 deletions(-) create mode 100644 src/accounting/utils/txn_types.py diff --git a/src/accounting/report/reports.py b/src/accounting/report/reports.py index 8ba07c3..1359f3a 100644 --- a/src/accounting/report/reports.py +++ b/src/accounting/report/reports.py @@ -27,13 +27,14 @@ from flask_sqlalchemy.query import Query from accounting import db from accounting.models import JournalEntry, Transaction, Account, Currency -from accounting.transaction.dispatcher import TXN_TYPE_OBJ, TransactionTypes from accounting.utils.pagination import Pagination +from accounting.utils.txn_types import TransactionTypeEnum from .period import Period from .period_choosers import PeriodChooser, \ JournalPeriodChooser from .report_chooser import ReportChooser, ReportType from .report_rows import ReportRow, JournalRow +import typing as t class JournalEntryReport(ABC): @@ -104,12 +105,12 @@ class JournalEntryReport(ABC): """ @property - def txn_types(self) -> TransactionTypes: + def txn_types(self) -> t.Type[TransactionTypeEnum]: """Returns the transaction types. :return: The transaction types. """ - return TXN_TYPE_OBJ + return TransactionTypeEnum def as_csv_download(self) -> Response: """Returns the journal entries as CSV download. diff --git a/src/accounting/templates/accounting/include/add-txn-material-fab.html b/src/accounting/templates/accounting/include/add-txn-material-fab.html index 8816eb2..80b3cb5 100644 --- a/src/accounting/templates/accounting/include/add-txn-material-fab.html +++ b/src/accounting/templates/accounting/include/add-txn-material-fab.html @@ -22,13 +22,13 @@ First written: 2023/2/25 {% if accounting_can_edit() %}
diff --git a/src/accounting/templates/accounting/report/journal.html b/src/accounting/templates/accounting/report/journal.html index fb506d1..2c62dfe 100644 --- a/src/accounting/templates/accounting/report/journal.html +++ b/src/accounting/templates/accounting/report/journal.html @@ -40,16 +40,16 @@ First written: 2023/3/4
-{% with types = report.txn_types %} +{% with txn_types = report.txn_types %} {% include "accounting/include/add-txn-material-fab.html" %} {% endwith %} diff --git a/src/accounting/templates/accounting/transaction/list.html b/src/accounting/templates/accounting/transaction/list.html index e212287..61d3e60 100644 --- a/src/accounting/templates/accounting/transaction/list.html +++ b/src/accounting/templates/accounting/transaction/list.html @@ -38,16 +38,16 @@ First written: 2023/2/18