diff --git a/src/accounting/report/converters.py b/src/accounting/report/converters.py index d0733a5..d455097 100644 --- a/src/accounting/report/converters.py +++ b/src/accounting/report/converters.py @@ -23,8 +23,8 @@ from flask import abort from werkzeug.routing import BaseConverter from accounting.models import Account +from accounting.report.period import Period from .utils.income_expense_account import IncomeExpensesAccount -from .utils.period import Period class PeriodConverter(BaseConverter): diff --git a/src/accounting/report/period/__init__.py b/src/accounting/report/period/__init__.py new file mode 100644 index 0000000..6034604 --- /dev/null +++ b/src/accounting/report/period/__init__.py @@ -0,0 +1,21 @@ +# The Mia! Accounting Flask Project. +# Author: imacat@mail.imacat.idv.tw (imacat), 2023/3/9 + +# Copyright (c) 2023 imacat. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""The period utility. + +""" +from .period import Period +from .period_chooser import PeriodChooser diff --git a/src/accounting/report/utils/period.py b/src/accounting/report/period/period.py similarity index 100% rename from src/accounting/report/utils/period.py rename to src/accounting/report/period/period.py diff --git a/src/accounting/report/utils/period_chooser.py b/src/accounting/report/period/period_chooser.py similarity index 100% rename from src/accounting/report/utils/period_chooser.py rename to src/accounting/report/period/period_chooser.py diff --git a/src/accounting/report/reports/balance_sheet.py b/src/accounting/report/reports/balance_sheet.py index 2de235b..ea0bd17 100644 --- a/src/accounting/report/reports/balance_sheet.py +++ b/src/accounting/report/reports/balance_sheet.py @@ -26,13 +26,12 @@ from accounting import db from accounting.locale import gettext from accounting.models import Currency, BaseAccount, Account, Transaction, \ JournalEntry +from accounting.report.period import Period, PeriodChooser from accounting.report.utils.base_page_params import BasePageParams from accounting.report.utils.base_report import BaseReport from accounting.report.utils.csv_export import BaseCSVRow, csv_download, \ period_spec from accounting.report.utils.option_link import OptionLink -from accounting.report.utils.period import Period -from accounting.report.utils.period_chooser import PeriodChooser from accounting.report.utils.report_chooser import ReportChooser from accounting.report.utils.report_type import ReportType from accounting.report.utils.urls import ledger_url, balance_sheet_url, \ diff --git a/src/accounting/report/reports/income_expenses.py b/src/accounting/report/reports/income_expenses.py index 7e4af3c..6a3a831 100644 --- a/src/accounting/report/reports/income_expenses.py +++ b/src/accounting/report/reports/income_expenses.py @@ -27,6 +27,7 @@ from sqlalchemy.orm import selectinload from accounting import db from accounting.locale import gettext from accounting.models import Currency, Account, Transaction, JournalEntry +from accounting.report.period import Period, PeriodChooser from accounting.report.utils.base_page_params import BasePageParams from accounting.report.utils.base_report import BaseReport from accounting.report.utils.csv_export import BaseCSVRow, csv_download, \ @@ -34,8 +35,6 @@ from accounting.report.utils.csv_export import BaseCSVRow, csv_download, \ from accounting.report.utils.income_expense_account import \ IncomeExpensesAccount from accounting.report.utils.option_link import OptionLink -from accounting.report.utils.period import Period -from accounting.report.utils.period_chooser import PeriodChooser from accounting.report.utils.report_chooser import ReportChooser from accounting.report.utils.report_type import ReportType from accounting.report.utils.urls import income_expenses_url diff --git a/src/accounting/report/reports/income_statement.py b/src/accounting/report/reports/income_statement.py index 5f3d295..655ae6e 100644 --- a/src/accounting/report/reports/income_statement.py +++ b/src/accounting/report/reports/income_statement.py @@ -26,13 +26,12 @@ from accounting import db from accounting.locale import gettext from accounting.models import Currency, BaseAccount, Account, Transaction, \ JournalEntry +from accounting.report.period import Period, PeriodChooser from accounting.report.utils.base_page_params import BasePageParams from accounting.report.utils.base_report import BaseReport from accounting.report.utils.csv_export import BaseCSVRow, csv_download, \ period_spec from accounting.report.utils.option_link import OptionLink -from accounting.report.utils.period import Period -from accounting.report.utils.period_chooser import PeriodChooser from accounting.report.utils.report_chooser import ReportChooser from accounting.report.utils.report_type import ReportType from accounting.report.utils.urls import ledger_url, income_statement_url diff --git a/src/accounting/report/reports/journal.py b/src/accounting/report/reports/journal.py index a5bcdb2..45243d7 100644 --- a/src/accounting/report/reports/journal.py +++ b/src/accounting/report/reports/journal.py @@ -26,12 +26,11 @@ from sqlalchemy.orm import selectinload from accounting.locale import gettext from accounting.models import Currency, Account, Transaction, JournalEntry +from accounting.report.period import Period, PeriodChooser from accounting.report.utils.base_page_params import BasePageParams from accounting.report.utils.base_report import BaseReport from accounting.report.utils.csv_export import BaseCSVRow, csv_download, \ period_spec -from accounting.report.utils.period import Period -from accounting.report.utils.period_chooser import PeriodChooser from accounting.report.utils.report_chooser import ReportChooser from accounting.report.utils.report_type import ReportType from accounting.report.utils.urls import journal_url diff --git a/src/accounting/report/reports/ledger.py b/src/accounting/report/reports/ledger.py index 9c297d9..43f9be8 100644 --- a/src/accounting/report/reports/ledger.py +++ b/src/accounting/report/reports/ledger.py @@ -27,13 +27,12 @@ from sqlalchemy.orm import selectinload from accounting import db from accounting.locale import gettext from accounting.models import Currency, Account, Transaction, JournalEntry +from accounting.report.period import Period, PeriodChooser from accounting.report.utils.base_page_params import BasePageParams from accounting.report.utils.base_report import BaseReport from accounting.report.utils.csv_export import BaseCSVRow, csv_download, \ period_spec from accounting.report.utils.option_link import OptionLink -from accounting.report.utils.period import Period -from accounting.report.utils.period_chooser import PeriodChooser from accounting.report.utils.report_chooser import ReportChooser from accounting.report.utils.report_type import ReportType from accounting.report.utils.urls import ledger_url diff --git a/src/accounting/report/reports/trial_balance.py b/src/accounting/report/reports/trial_balance.py index 16656d6..d6a84c2 100644 --- a/src/accounting/report/reports/trial_balance.py +++ b/src/accounting/report/reports/trial_balance.py @@ -25,13 +25,12 @@ from flask import Response, render_template from accounting import db from accounting.locale import gettext from accounting.models import Currency, Account, Transaction, JournalEntry +from accounting.report.period import Period, PeriodChooser from accounting.report.utils.base_page_params import BasePageParams from accounting.report.utils.base_report import BaseReport from accounting.report.utils.csv_export import BaseCSVRow, csv_download, \ period_spec from accounting.report.utils.option_link import OptionLink -from accounting.report.utils.period import Period -from accounting.report.utils.period_chooser import PeriodChooser from accounting.report.utils.report_chooser import ReportChooser from accounting.report.utils.report_type import ReportType from accounting.report.utils.urls import ledger_url, trial_balance_url diff --git a/src/accounting/report/utils/csv_export.py b/src/accounting/report/utils/csv_export.py index 1ab208b..ecf3b35 100644 --- a/src/accounting/report/utils/csv_export.py +++ b/src/accounting/report/utils/csv_export.py @@ -25,7 +25,7 @@ from io import StringIO from flask import Response -from .period import Period +from accounting.report.period import Period class BaseCSVRow(ABC): diff --git a/src/accounting/report/utils/report_chooser.py b/src/accounting/report/utils/report_chooser.py index 2b818ea..1200048 100644 --- a/src/accounting/report/utils/report_chooser.py +++ b/src/accounting/report/utils/report_chooser.py @@ -28,10 +28,10 @@ from flask_babel import LazyString from accounting import db from accounting.locale import gettext from accounting.models import Currency, Account +from accounting.report.period import Period from accounting.template_globals import default_currency_code from .income_expense_account import IncomeExpensesAccount from .option_link import OptionLink -from .period import Period from .report_type import ReportType from .urls import journal_url, ledger_url, income_expenses_url, \ trial_balance_url, income_statement_url, balance_sheet_url diff --git a/src/accounting/report/utils/urls.py b/src/accounting/report/utils/urls.py index e5945ac..8ecbc58 100644 --- a/src/accounting/report/utils/urls.py +++ b/src/accounting/report/utils/urls.py @@ -20,8 +20,8 @@ from flask import url_for from accounting.models import Currency, Account +from accounting.report.period import Period from .income_expense_account import IncomeExpensesAccount -from .period import Period def journal_url(period: Period) \ diff --git a/src/accounting/report/views.py b/src/accounting/report/views.py index 7478c64..7e20be2 100644 --- a/src/accounting/report/views.py +++ b/src/accounting/report/views.py @@ -20,12 +20,12 @@ from flask import Blueprint, request, Response from accounting.models import Currency, Account +from accounting.report.period import Period from accounting.utils.permission import has_permission, can_view from .reports import Journal, Ledger, IncomeExpenses, TrialBalance, \ IncomeStatement, BalanceSheet, Search from .template_filters import format_amount from .utils.income_expense_account import IncomeExpensesAccount -from .utils.period import Period bp: Blueprint = Blueprint("report", __name__) """The view blueprint for the reports."""