Moved the IncomeExpensesAccount data model from the "accounting.report.utils.ie_account" module to the "accounting.utils.ie_account" module.
This commit is contained in:
parent
e2325f08d0
commit
656762850c
@ -23,8 +23,8 @@ from flask import abort
|
|||||||
from werkzeug.routing import BaseConverter
|
from werkzeug.routing import BaseConverter
|
||||||
|
|
||||||
from accounting.models import Account
|
from accounting.models import Account
|
||||||
|
from accounting.utils.ie_account import IncomeExpensesAccount
|
||||||
from .period import Period, get_period
|
from .period import Period, get_period
|
||||||
from .utils.ie_account import IncomeExpensesAccount
|
|
||||||
|
|
||||||
|
|
||||||
class PeriodConverter(BaseConverter):
|
class PeriodConverter(BaseConverter):
|
||||||
|
@ -33,12 +33,12 @@ from accounting.report.utils.base_page_params import BasePageParams
|
|||||||
from accounting.report.utils.base_report import BaseReport
|
from accounting.report.utils.base_report import BaseReport
|
||||||
from accounting.report.utils.csv_export import BaseCSVRow, csv_download, \
|
from accounting.report.utils.csv_export import BaseCSVRow, csv_download, \
|
||||||
period_spec
|
period_spec
|
||||||
from accounting.report.utils.ie_account import IncomeExpensesAccount
|
|
||||||
from accounting.report.utils.option_link import OptionLink
|
from accounting.report.utils.option_link import OptionLink
|
||||||
from accounting.report.utils.report_chooser import ReportChooser
|
from accounting.report.utils.report_chooser import ReportChooser
|
||||||
from accounting.report.utils.report_type import ReportType
|
from accounting.report.utils.report_type import ReportType
|
||||||
from accounting.report.utils.urls import income_expenses_url
|
from accounting.report.utils.urls import income_expenses_url
|
||||||
from accounting.utils.cast import be
|
from accounting.utils.cast import be
|
||||||
|
from accounting.utils.ie_account import IncomeExpensesAccount
|
||||||
from accounting.utils.pagination import Pagination
|
from accounting.utils.pagination import Pagination
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,53 +17,10 @@
|
|||||||
"""The pseudo account for the income and expenses log.
|
"""The pseudo account for the income and expenses log.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
import typing as t
|
|
||||||
|
|
||||||
from flask import current_app
|
from flask import current_app
|
||||||
|
|
||||||
from accounting.locale import gettext
|
|
||||||
from accounting.models import Account
|
from accounting.models import Account
|
||||||
|
from accounting.utils.ie_account import IncomeExpensesAccount
|
||||||
|
|
||||||
class IncomeExpensesAccount:
|
|
||||||
"""The pseudo account for the income and expenses log."""
|
|
||||||
CURRENT_AL_CODE: str = "0000-000"
|
|
||||||
"""The account code for the current assets and liabilities."""
|
|
||||||
|
|
||||||
def __init__(self, account: Account | None = None):
|
|
||||||
"""Constructs the pseudo account for the income and expenses log.
|
|
||||||
|
|
||||||
:param account: The actual account.
|
|
||||||
"""
|
|
||||||
self.account: Account | None = account
|
|
||||||
self.id: int = -1 if account is None else account.id
|
|
||||||
"""The ID."""
|
|
||||||
self.code: str = "" if account is None else account.code
|
|
||||||
"""The code."""
|
|
||||||
self.title: str = "" if account is None else account.title
|
|
||||||
"""The title."""
|
|
||||||
self.str: str = "" if account is None else str(account)
|
|
||||||
"""The string representation of the account."""
|
|
||||||
|
|
||||||
def __str__(self) -> str:
|
|
||||||
"""Returns the string representation of the account.
|
|
||||||
|
|
||||||
:return: The string representation of the account.
|
|
||||||
"""
|
|
||||||
return self.str
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def current_assets_and_liabilities(cls) -> t.Self:
|
|
||||||
"""Returns the pseudo account for current assets and liabilities.
|
|
||||||
|
|
||||||
:return: The pseudo account for current assets and liabilities.
|
|
||||||
"""
|
|
||||||
account: cls = cls()
|
|
||||||
account.id = 0
|
|
||||||
account.code = cls.CURRENT_AL_CODE
|
|
||||||
account.title = gettext("current assets and liabilities")
|
|
||||||
account.str = account.title
|
|
||||||
return account
|
|
||||||
|
|
||||||
|
|
||||||
def default_ie_account_code() -> str:
|
def default_ie_account_code() -> str:
|
||||||
|
@ -30,7 +30,7 @@ from accounting.locale import gettext
|
|||||||
from accounting.models import Currency, Account
|
from accounting.models import Currency, Account
|
||||||
from accounting.report.period import Period, get_period
|
from accounting.report.period import Period, get_period
|
||||||
from accounting.template_globals import default_currency_code
|
from accounting.template_globals import default_currency_code
|
||||||
from .ie_account import IncomeExpensesAccount
|
from accounting.utils.ie_account import IncomeExpensesAccount
|
||||||
from .option_link import OptionLink
|
from .option_link import OptionLink
|
||||||
from .report_type import ReportType
|
from .report_type import ReportType
|
||||||
from .urls import journal_url, ledger_url, income_expenses_url, \
|
from .urls import journal_url, ledger_url, income_expenses_url, \
|
||||||
|
@ -21,8 +21,9 @@ from flask import url_for
|
|||||||
|
|
||||||
from accounting.models import Currency, Account
|
from accounting.models import Currency, Account
|
||||||
from accounting.report.period import Period
|
from accounting.report.period import Period
|
||||||
|
from accounting.report.utils.ie_account import default_ie_account_code
|
||||||
from accounting.template_globals import default_currency_code
|
from accounting.template_globals import default_currency_code
|
||||||
from .ie_account import IncomeExpensesAccount, default_ie_account_code
|
from accounting.utils.ie_account import IncomeExpensesAccount
|
||||||
|
|
||||||
|
|
||||||
def journal_url(period: Period) \
|
def journal_url(period: Period) \
|
||||||
|
@ -23,11 +23,12 @@ from accounting import db
|
|||||||
from accounting.models import Currency, Account
|
from accounting.models import Currency, Account
|
||||||
from accounting.report.period import Period, get_period
|
from accounting.report.period import Period, get_period
|
||||||
from accounting.template_globals import default_currency_code
|
from accounting.template_globals import default_currency_code
|
||||||
|
from accounting.utils.ie_account import IncomeExpensesAccount
|
||||||
from accounting.utils.permission import has_permission, can_view
|
from accounting.utils.permission import has_permission, can_view
|
||||||
from .reports import Journal, Ledger, IncomeExpenses, TrialBalance, \
|
from .reports import Journal, Ledger, IncomeExpenses, TrialBalance, \
|
||||||
IncomeStatement, BalanceSheet, Search
|
IncomeStatement, BalanceSheet, Search
|
||||||
from .template_filters import format_amount
|
from .template_filters import format_amount
|
||||||
from .utils.ie_account import IncomeExpensesAccount, default_ie_account
|
from .utils.ie_account import default_ie_account
|
||||||
|
|
||||||
bp: Blueprint = Blueprint("report", __name__)
|
bp: Blueprint = Blueprint("report", __name__)
|
||||||
"""The view blueprint for the reports."""
|
"""The view blueprint for the reports."""
|
||||||
|
64
src/accounting/utils/ie_account.py
Normal file
64
src/accounting/utils/ie_account.py
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
# The Mia! Accounting Flask Project.
|
||||||
|
# Author: imacat@mail.imacat.idv.tw (imacat), 2023/3/22
|
||||||
|
|
||||||
|
# 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 pseudo account for the income and expenses log.
|
||||||
|
|
||||||
|
"""
|
||||||
|
import typing as t
|
||||||
|
|
||||||
|
from accounting.locale import gettext
|
||||||
|
from accounting.models import Account
|
||||||
|
|
||||||
|
|
||||||
|
class IncomeExpensesAccount:
|
||||||
|
"""The pseudo account for the income and expenses log."""
|
||||||
|
CURRENT_AL_CODE: str = "0000-000"
|
||||||
|
"""The account code for the current assets and liabilities."""
|
||||||
|
|
||||||
|
def __init__(self, account: Account | None = None):
|
||||||
|
"""Constructs the pseudo account for the income and expenses log.
|
||||||
|
|
||||||
|
:param account: The actual account.
|
||||||
|
"""
|
||||||
|
self.account: Account | None = account
|
||||||
|
self.id: int = -1 if account is None else account.id
|
||||||
|
"""The ID."""
|
||||||
|
self.code: str = "" if account is None else account.code
|
||||||
|
"""The code."""
|
||||||
|
self.title: str = "" if account is None else account.title
|
||||||
|
"""The title."""
|
||||||
|
self.str: str = "" if account is None else str(account)
|
||||||
|
"""The string representation of the account."""
|
||||||
|
|
||||||
|
def __str__(self) -> str:
|
||||||
|
"""Returns the string representation of the account.
|
||||||
|
|
||||||
|
:return: The string representation of the account.
|
||||||
|
"""
|
||||||
|
return self.str
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def current_assets_and_liabilities(cls) -> t.Self:
|
||||||
|
"""Returns the pseudo account for current assets and liabilities.
|
||||||
|
|
||||||
|
:return: The pseudo account for current assets and liabilities.
|
||||||
|
"""
|
||||||
|
account: cls = cls()
|
||||||
|
account.id = 0
|
||||||
|
account.code = cls.CURRENT_AL_CODE
|
||||||
|
account.title = gettext("current assets and liabilities")
|
||||||
|
account.str = account.title
|
||||||
|
return account
|
Loading…
Reference in New Issue
Block a user