diff --git a/src/accounting/__init__.py b/src/accounting/__init__.py index 6e60cc2..47f7b04 100644 --- a/src/accounting/__init__.py +++ b/src/accounting/__init__.py @@ -1,7 +1,7 @@ # The Mia! Accounting Project. # Author: imacat@mail.imacat.idv.tw (imacat), 2023/1/25 -# Copyright (c) 2023-2024 imacat. +# Copyright (c) 2023-2026 imacat. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ from pathlib import Path from flask import Flask, Blueprint from flask_sqlalchemy import SQLAlchemy -from accounting.utils.user import UserUtilityInterface +from .utils.user import UserUtilityInterface VERSION: str = "1.6.1" """The package version.""" diff --git a/src/accounting/account/commands.py b/src/accounting/account/commands.py index df751d0..e5c51c6 100644 --- a/src/accounting/account/commands.py +++ b/src/accounting/account/commands.py @@ -1,7 +1,7 @@ # The Mia! Accounting Project. # Author: imacat@mail.imacat.idv.tw (imacat), 2023/1/30 -# Copyright (c) 2023-2024 imacat. +# Copyright (c) 2023-2026 imacat. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -23,9 +23,9 @@ from typing import Any import click import sqlalchemy as sa -from accounting import db -from accounting.models import BaseAccount, Account, AccountL10n -from accounting.utils.user import get_user_pk +from .. import db +from ..models import BaseAccount, Account, AccountL10n +from ..utils.user import get_user_pk type AccountData = tuple[int, str, int, str, str, str, bool] """The format of the account data, as a list of (ID, base account code, number, diff --git a/src/accounting/account/converters.py b/src/accounting/account/converters.py index faa3c3c..f225a2d 100644 --- a/src/accounting/account/converters.py +++ b/src/accounting/account/converters.py @@ -1,7 +1,7 @@ # The Mia! Accounting Project. # Author: imacat@mail.imacat.idv.tw (imacat), 2023/1/31 -# Copyright (c) 2023 imacat. +# Copyright (c) 2023-2026 imacat. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ from flask import abort from werkzeug.routing import BaseConverter -from accounting.models import Account +from ..models import Account class AccountConverter(BaseConverter): diff --git a/src/accounting/account/forms.py b/src/accounting/account/forms.py index 9772bb8..7a31933 100644 --- a/src/accounting/account/forms.py +++ b/src/accounting/account/forms.py @@ -1,7 +1,7 @@ # The Mia! Accounting Project. # Author: imacat@mail.imacat.idv.tw (imacat), 2023/2/1 -# Copyright (c) 2023 imacat. +# Copyright (c) 2023-2026 imacat. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -23,12 +23,12 @@ from flask_wtf import FlaskForm from wtforms import StringField, BooleanField from wtforms.validators import DataRequired, ValidationError -from accounting import db -from accounting.locale import lazy_gettext -from accounting.models import BaseAccount, Account -from accounting.utils.random_id import new_id -from accounting.utils.strip_text import strip_text -from accounting.utils.user import get_current_user_pk +from .. import db +from ..locale import lazy_gettext +from ..models import BaseAccount, Account +from ..utils.random_id import new_id +from ..utils.strip_text import strip_text +from ..utils.user import get_current_user_pk class BaseAccountExists: diff --git a/src/accounting/account/queries.py b/src/accounting/account/queries.py index d6d6373..f7bbecd 100644 --- a/src/accounting/account/queries.py +++ b/src/accounting/account/queries.py @@ -1,7 +1,7 @@ # The Mia! Accounting Project. # Author: imacat@mail.imacat.idv.tw (imacat), 2023/1/30 -# Copyright (c) 2023 imacat. +# Copyright (c) 2023-2026 imacat. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -20,9 +20,9 @@ import sqlalchemy as sa from flask import request -from accounting.locale import gettext -from accounting.models import Account, AccountL10n -from accounting.utils.query import parse_query_keywords +from ..locale import gettext +from ..models import Account, AccountL10n +from ..utils.query import parse_query_keywords def get_account_query() -> list[Account]: diff --git a/src/accounting/account/views.py b/src/accounting/account/views.py index b9a8cf5..0a56d5e 100644 --- a/src/accounting/account/views.py +++ b/src/accounting/account/views.py @@ -24,17 +24,17 @@ from flask import Blueprint, render_template, session, redirect, flash, \ url_for, request, Response from werkzeug.datastructures import ImmutableMultiDict -from accounting import db -from accounting.locale import lazy_gettext -from accounting.models import Account, BaseAccount -from accounting.utils.cast import s -from accounting.utils.flash_errors import flash_form_errors -from accounting.utils.next_uri import inherit_next, or_next -from accounting.utils.pagination import Pagination -from accounting.utils.permission import can_view, has_permission, can_edit -from accounting.utils.user import get_current_user_pk from .forms import AccountForm, sort_accounts_in, AccountReorderForm from .queries import get_account_query +from .. import db +from ..locale import lazy_gettext +from ..models import Account, BaseAccount +from ..utils.cast import s +from ..utils.flash_errors import flash_form_errors +from ..utils.next_uri import inherit_next, or_next +from ..utils.pagination import Pagination +from ..utils.permission import can_view, has_permission, can_edit +from ..utils.user import get_current_user_pk bp: Blueprint = Blueprint("account", __name__) """The view blueprint for the account management.""" diff --git a/src/accounting/base_account/commands.py b/src/accounting/base_account/commands.py index 234e7a2..2a4c6fb 100644 --- a/src/accounting/base_account/commands.py +++ b/src/accounting/base_account/commands.py @@ -21,10 +21,9 @@ import csv import sqlalchemy as sa -from accounting import data_dir -from accounting import db -from accounting.models import BaseAccount, BaseAccountL10n -from accounting.utils.title_case import title_case +from .. import db, data_dir +from ..models import BaseAccount, BaseAccountL10n +from ..utils.title_case import title_case def init_base_accounts_command() -> None: diff --git a/src/accounting/base_account/converters.py b/src/accounting/base_account/converters.py index d5955ae..7627e84 100644 --- a/src/accounting/base_account/converters.py +++ b/src/accounting/base_account/converters.py @@ -1,7 +1,7 @@ # The Mia! Accounting Project. # Author: imacat@mail.imacat.idv.tw (imacat), 2023/2/1 -# Copyright (c) 2023 imacat. +# Copyright (c) 2023-2026 imacat. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -20,8 +20,8 @@ from flask import abort from werkzeug.routing import BaseConverter -from accounting import db -from accounting.models import BaseAccount +from .. import db +from ..models import BaseAccount class BaseAccountConverter(BaseConverter): diff --git a/src/accounting/base_account/queries.py b/src/accounting/base_account/queries.py index f8091ee..37d7682 100644 --- a/src/accounting/base_account/queries.py +++ b/src/accounting/base_account/queries.py @@ -1,7 +1,7 @@ # The Mia! Accounting Project. # Author: imacat@mail.imacat.idv.tw (imacat), 2023/1/26 -# Copyright (c) 2023 imacat. +# Copyright (c) 2023-2026 imacat. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -20,8 +20,8 @@ import sqlalchemy as sa from flask import request -from accounting.models import BaseAccount, BaseAccountL10n -from accounting.utils.query import parse_query_keywords +from ..models import BaseAccount, BaseAccountL10n +from ..utils.query import parse_query_keywords def get_base_account_query() -> list[BaseAccount]: diff --git a/src/accounting/base_account/views.py b/src/accounting/base_account/views.py index a177368..22614e5 100644 --- a/src/accounting/base_account/views.py +++ b/src/accounting/base_account/views.py @@ -19,10 +19,10 @@ """ from flask import Blueprint, render_template -from accounting.models import BaseAccount -from accounting.utils.pagination import Pagination -from accounting.utils.permission import has_permission, can_view from .queries import get_base_account_query +from ..models import BaseAccount +from ..utils.pagination import Pagination +from ..utils.permission import has_permission, can_view bp: Blueprint = Blueprint("base-account", __name__) """The view blueprint for the base account management.""" diff --git a/src/accounting/commands.py b/src/accounting/commands.py index 4d321dd..d1c6ba4 100644 --- a/src/accounting/commands.py +++ b/src/accounting/commands.py @@ -1,7 +1,7 @@ # The Mia! Accounting Project. # Author: imacat@mail.imacat.idv.tw (imacat), 2023/4/10 -# Copyright (c) 2023 imacat. +# Copyright (c) 2023-2026 imacat. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -20,16 +20,16 @@ import os import click +import sqlalchemy as sa from flask.cli import with_appcontext -from accounting import db -from accounting.account import init_accounts_command -from accounting.base_account import init_base_accounts_command -from accounting.currency import init_currencies_command -from accounting.models import BaseAccount, Account -from accounting.utils.title_case import title_case -from accounting.utils.user import has_user, get_user_pk -import sqlalchemy as sa +from . import db +from .account import init_accounts_command +from .base_account import init_base_accounts_command +from .currency import init_currencies_command +from .models import BaseAccount, Account +from .utils.title_case import title_case +from .utils.user import has_user, get_user_pk def __validate_username(ctx: click.core.Context, param: click.core.Option, diff --git a/src/accounting/currency/commands.py b/src/accounting/currency/commands.py index 1ff9a85..5d79c85 100644 --- a/src/accounting/currency/commands.py +++ b/src/accounting/currency/commands.py @@ -1,7 +1,7 @@ # The Mia! Accounting Project. # Author: imacat@mail.imacat.idv.tw (imacat), 2023/2/6 -# Copyright (c) 2023 imacat. +# Copyright (c) 2023-2026 imacat. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -22,9 +22,9 @@ from typing import Any import sqlalchemy as sa -from accounting import db, data_dir -from accounting.models import Currency, CurrencyL10n -from accounting.utils.user import get_user_pk +from .. import db, data_dir +from ..models import Currency, CurrencyL10n +from ..utils.user import get_user_pk def init_currencies_command(username: str) -> None: diff --git a/src/accounting/currency/converters.py b/src/accounting/currency/converters.py index 0610b96..30edcc2 100644 --- a/src/accounting/currency/converters.py +++ b/src/accounting/currency/converters.py @@ -1,7 +1,7 @@ # The Mia! Accounting Project. # Author: imacat@mail.imacat.idv.tw (imacat), 2023/2/6 -# Copyright (c) 2023 imacat. +# Copyright (c) 2023-2026 imacat. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -20,8 +20,8 @@ from flask import abort from werkzeug.routing import BaseConverter -from accounting import db -from accounting.models import Currency +from .. import db +from ..models import Currency class CurrencyConverter(BaseConverter): diff --git a/src/accounting/currency/forms.py b/src/accounting/currency/forms.py index febae7b..ca58227 100644 --- a/src/accounting/currency/forms.py +++ b/src/accounting/currency/forms.py @@ -1,7 +1,7 @@ # The Mia! Accounting Project. # Author: imacat@mail.imacat.idv.tw (imacat), 2023/2/6 -# Copyright (c) 2023 imacat. +# Copyright (c) 2023-2026 imacat. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -21,11 +21,11 @@ from flask_wtf import FlaskForm from wtforms import StringField, ValidationError from wtforms.validators import DataRequired, Regexp, NoneOf -from accounting import db -from accounting.locale import lazy_gettext -from accounting.models import Currency -from accounting.utils.strip_text import strip_text -from accounting.utils.user import get_current_user_pk +from .. import db +from ..locale import lazy_gettext +from ..models import Currency +from ..utils.strip_text import strip_text +from ..utils.user import get_current_user_pk class CodeUnique: diff --git a/src/accounting/currency/queries.py b/src/accounting/currency/queries.py index 29137c4..4648f06 100644 --- a/src/accounting/currency/queries.py +++ b/src/accounting/currency/queries.py @@ -1,7 +1,7 @@ # The Mia! Accounting Project. # Author: imacat@mail.imacat.idv.tw (imacat), 2023/2/6 -# Copyright (c) 2023 imacat. +# Copyright (c) 2023-2026 imacat. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -20,8 +20,8 @@ import sqlalchemy as sa from flask import request -from accounting.models import Currency, CurrencyL10n -from accounting.utils.query import parse_query_keywords +from ..models import Currency, CurrencyL10n +from ..utils.query import parse_query_keywords def get_currency_query() -> list[Currency]: diff --git a/src/accounting/currency/views.py b/src/accounting/currency/views.py index bf956e3..e142d43 100644 --- a/src/accounting/currency/views.py +++ b/src/accounting/currency/views.py @@ -24,17 +24,17 @@ from flask import Blueprint, render_template, redirect, session, request, \ flash, url_for, Response from werkzeug.datastructures import ImmutableMultiDict -from accounting import db -from accounting.locale import lazy_gettext -from accounting.models import Currency -from accounting.utils.cast import s -from accounting.utils.flash_errors import flash_form_errors -from accounting.utils.next_uri import inherit_next, or_next -from accounting.utils.pagination import Pagination -from accounting.utils.permission import has_permission, can_view, can_edit -from accounting.utils.user import get_current_user_pk from .forms import CurrencyForm from .queries import get_currency_query +from .. import db +from ..locale import lazy_gettext +from ..models import Currency +from ..utils.cast import s +from ..utils.flash_errors import flash_form_errors +from ..utils.next_uri import inherit_next, or_next +from ..utils.pagination import Pagination +from ..utils.permission import has_permission, can_view, can_edit +from ..utils.user import get_current_user_pk bp: Blueprint = Blueprint("currency", __name__) """The view blueprint for the currency management.""" diff --git a/src/accounting/forms.py b/src/accounting/forms.py index 0b01aa6..515d4b2 100644 --- a/src/accounting/forms.py +++ b/src/accounting/forms.py @@ -1,7 +1,7 @@ # The Mia! Accounting Project. # Author: imacat@mail.imacat.idv.tw (imacat), 2023/3/22 -# Copyright (c) 2023 imacat. +# Copyright (c) 2023-2026 imacat. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -24,10 +24,9 @@ from flask_wtf import FlaskForm from wtforms import StringField, ValidationError from wtforms.validators import DataRequired -from accounting import db -from accounting.locale import lazy_gettext -from accounting.models import Currency, Account - +from . import db +from .locale import lazy_gettext +from .models import Currency, Account ACCOUNT_REQUIRED: DataRequired = DataRequired( lazy_gettext("Please select the account.")) diff --git a/src/accounting/journal_entry/converters.py b/src/accounting/journal_entry/converters.py index 33b942f..05bf379 100644 --- a/src/accounting/journal_entry/converters.py +++ b/src/accounting/journal_entry/converters.py @@ -1,7 +1,7 @@ # The Mia! Accounting Project. # Author: imacat@mail.imacat.idv.tw (imacat), 2023/2/19 -# Copyright (c) 2023 imacat. +# Copyright (c) 2023-2026 imacat. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -22,9 +22,9 @@ import datetime as dt from flask import abort from werkzeug.routing import BaseConverter -from accounting import db -from accounting.models import JournalEntry -from accounting.utils.journal_entry_types import JournalEntryType +from .. import db +from ..models import JournalEntry +from ..utils.journal_entry_types import JournalEntryType class JournalEntryConverter(BaseConverter): diff --git a/src/accounting/journal_entry/forms/currency.py b/src/accounting/journal_entry/forms/currency.py index 67f44e7..8bd7cc8 100644 --- a/src/accounting/journal_entry/forms/currency.py +++ b/src/accounting/journal_entry/forms/currency.py @@ -1,7 +1,7 @@ # The Mia! Accounting Project. # Author: imacat@mail.imacat.idv.tw (imacat), 2023/3/10 -# Copyright (c) 2023 imacat. +# Copyright (c) 2023-2026 imacat. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -26,13 +26,13 @@ from wtforms import StringField, ValidationError, FieldList, IntegerField, \ BooleanField, FormField from wtforms.validators import DataRequired -from accounting import db -from accounting.forms import CurrencyExists -from accounting.locale import lazy_gettext -from accounting.models import JournalEntryLineItem -from accounting.utils.offset_alias import offset_alias -from accounting.utils.strip_text import strip_text from .line_item import LineItemForm, CreditLineItemForm, DebitLineItemForm +from ... import db +from ...forms import CurrencyExists +from ...locale import lazy_gettext +from ...models import JournalEntryLineItem +from ...utils.offset_alias import offset_alias +from ...utils.strip_text import strip_text CURRENCY_REQUIRED: DataRequired = DataRequired( lazy_gettext("Please select the currency.")) diff --git a/src/accounting/journal_entry/forms/journal_entry.py b/src/accounting/journal_entry/forms/journal_entry.py index 126034f..839d801 100644 --- a/src/accounting/journal_entry/forms/journal_entry.py +++ b/src/accounting/journal_entry/forms/journal_entry.py @@ -1,7 +1,7 @@ # The Mia! Accounting Project. # Author: imacat@mail.imacat.idv.tw (imacat), 2023/2/18 -# Copyright (c) 2023-2024 imacat. +# Copyright (c) 2023-2026 imacat. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -28,21 +28,20 @@ from wtforms import DateField, FieldList, FormField, TextAreaField, \ BooleanField from wtforms.validators import DataRequired, ValidationError -from accounting import db -from accounting.journal_entry.utils.account_option import AccountOption -from accounting.journal_entry.utils.description_editor import DescriptionEditor -from accounting.journal_entry.utils.original_line_items import \ - get_selectable_original_line_items -from accounting.locale import lazy_gettext -from accounting.models import JournalEntry, Account, JournalEntryLineItem, \ - JournalEntryCurrency -from accounting.utils.random_id import new_id -from accounting.utils.strip_text import strip_multiline_text -from accounting.utils.user import get_current_user_pk from .currency import CurrencyForm, CashReceiptCurrencyForm, \ CashDisbursementCurrencyForm, TransferCurrencyForm from .line_item import LineItemForm, DebitLineItemForm, CreditLineItemForm from .reorder import sort_journal_entries_in +from ..utils.account_option import AccountOption +from ..utils.description_editor import DescriptionEditor +from ..utils.original_line_items import get_selectable_original_line_items +from ... import db +from ...locale import lazy_gettext +from ...models import JournalEntry, Account, JournalEntryLineItem, \ + JournalEntryCurrency +from ...utils.random_id import new_id +from ...utils.strip_text import strip_multiline_text +from ...utils.user import get_current_user_pk DATE_REQUIRED: DataRequired = DataRequired( lazy_gettext("Please fill in the date.")) diff --git a/src/accounting/journal_entry/forms/line_item.py b/src/accounting/journal_entry/forms/line_item.py index 7b30c6c..27e8c72 100644 --- a/src/accounting/journal_entry/forms/line_item.py +++ b/src/accounting/journal_entry/forms/line_item.py @@ -1,7 +1,7 @@ # The Mia! Accounting Project. # Author: imacat@mail.imacat.idv.tw (imacat), 2023/3/10 -# Copyright (c) 2023 imacat. +# Copyright (c) 2023-2026 imacat. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -27,15 +27,15 @@ from sqlalchemy.orm import selectinload from wtforms import StringField, ValidationError, DecimalField, IntegerField from wtforms.validators import Optional -from accounting import db -from accounting.forms import ACCOUNT_REQUIRED, AccountExists, IsDebitAccount, \ +from ... import db +from ...forms import ACCOUNT_REQUIRED, AccountExists, IsDebitAccount, \ IsCreditAccount -from accounting.locale import lazy_gettext -from accounting.models import Account, JournalEntry, JournalEntryLineItem -from accounting.template_filters import format_amount -from accounting.utils.random_id import new_id -from accounting.utils.strip_text import strip_text -from accounting.utils.user import get_current_user_pk +from ...locale import lazy_gettext +from ...models import Account, JournalEntry, JournalEntryLineItem +from ...template_filters import format_amount +from ...utils.random_id import new_id +from ...utils.strip_text import strip_text +from ...utils.user import get_current_user_pk class OriginalLineItemExists: diff --git a/src/accounting/journal_entry/forms/reorder.py b/src/accounting/journal_entry/forms/reorder.py index 1284fbc..2d073d7 100644 --- a/src/accounting/journal_entry/forms/reorder.py +++ b/src/accounting/journal_entry/forms/reorder.py @@ -1,7 +1,7 @@ # The Mia! Accounting Project. # Author: imacat@mail.imacat.idv.tw (imacat), 2023/3/10 -# Copyright (c) 2023 imacat. +# Copyright (c) 2023-2026 imacat. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -22,8 +22,8 @@ import datetime as dt import sqlalchemy as sa from flask import request -from accounting import db -from accounting.models import JournalEntry +from ... import db +from ...models import JournalEntry def sort_journal_entries_in(date: dt.date, exclude: int | None = None) -> None: diff --git a/src/accounting/journal_entry/utils/account_option.py b/src/accounting/journal_entry/utils/account_option.py index 3a4bc53..ba3979f 100644 --- a/src/accounting/journal_entry/utils/account_option.py +++ b/src/accounting/journal_entry/utils/account_option.py @@ -1,7 +1,7 @@ # The Mia! Accounting Project. # Author: imacat@mail.imacat.idv.tw (imacat), 2023/3/10 -# Copyright (c) 2023 imacat. +# Copyright (c) 2023-2026 imacat. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,7 +17,7 @@ """The account option for the journal entry management. """ -from accounting.models import Account +from ...models import Account class AccountOption: diff --git a/src/accounting/journal_entry/utils/description_editor.py b/src/accounting/journal_entry/utils/description_editor.py index 269469e..24d75be 100644 --- a/src/accounting/journal_entry/utils/description_editor.py +++ b/src/accounting/journal_entry/utils/description_editor.py @@ -22,9 +22,9 @@ from typing import Literal import sqlalchemy as sa -from accounting import db -from accounting.models import Account, JournalEntryLineItem -from accounting.utils.options import options, Recurring +from ... import db +from ...models import Account, JournalEntryLineItem +from ...utils.options import options, Recurring class DescriptionAccount: diff --git a/src/accounting/journal_entry/utils/operators.py b/src/accounting/journal_entry/utils/operators.py index 79455b5..57d438a 100644 --- a/src/accounting/journal_entry/utils/operators.py +++ b/src/accounting/journal_entry/utils/operators.py @@ -1,7 +1,7 @@ # The Mia! Accounting Project. # Author: imacat@mail.imacat.idv.tw (imacat), 2023/2/19 -# Copyright (c) 2023 imacat. +# Copyright (c) 2023-2026 imacat. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -23,13 +23,12 @@ from typing import Type from flask import render_template, request, abort from flask_wtf import FlaskForm -from accounting.journal_entry.forms import JournalEntryForm, \ - CashReceiptJournalEntryForm, CashDisbursementJournalEntryForm, \ - TransferJournalEntryForm -from accounting.journal_entry.forms.line_item import LineItemForm -from accounting.models import JournalEntry -from accounting.template_globals import default_currency_code -from accounting.utils.journal_entry_types import JournalEntryType +from ..forms import JournalEntryForm, CashReceiptJournalEntryForm, \ + CashDisbursementJournalEntryForm, TransferJournalEntryForm +from ..forms.line_item import LineItemForm +from ...models import JournalEntry +from ...template_globals import default_currency_code +from ...utils.journal_entry_types import JournalEntryType class JournalEntryOperator(ABC): diff --git a/src/accounting/journal_entry/utils/original_line_items.py b/src/accounting/journal_entry/utils/original_line_items.py index 2321ef3..7d06a95 100644 --- a/src/accounting/journal_entry/utils/original_line_items.py +++ b/src/accounting/journal_entry/utils/original_line_items.py @@ -1,7 +1,7 @@ # The Mia! Accounting Project. # Author: imacat@mail.imacat.idv.tw (imacat), 2023/3/10 -# Copyright (c) 2023 imacat. +# Copyright (c) 2023-2026 imacat. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -22,9 +22,9 @@ from decimal import Decimal import sqlalchemy as sa from sqlalchemy.orm import selectinload -from accounting import db -from accounting.models import Account, JournalEntry, JournalEntryLineItem -from accounting.utils.offset_alias import offset_alias +from ... import db +from ...models import Account, JournalEntry, JournalEntryLineItem +from ...utils.offset_alias import offset_alias def get_selectable_original_line_items( diff --git a/src/accounting/journal_entry/views.py b/src/accounting/journal_entry/views.py index 7560fa0..227be5d 100644 --- a/src/accounting/journal_entry/views.py +++ b/src/accounting/journal_entry/views.py @@ -25,21 +25,21 @@ from flask import Blueprint, render_template, session, redirect, request, \ flash, url_for, Response from werkzeug.datastructures import ImmutableMultiDict -from accounting import db -from accounting.locale import lazy_gettext -from accounting.models import JournalEntry -from accounting.utils.cast import s -from accounting.utils.flash_errors import flash_form_errors -from accounting.utils.journal_entry_types import JournalEntryType -from accounting.utils.next_uri import inherit_next, or_next -from accounting.utils.permission import has_permission, can_view, can_edit -from accounting.utils.timezone import get_tz_today -from accounting.utils.user import get_current_user_pk from .forms import sort_journal_entries_in, JournalEntryReorderForm from .template_filters import with_type, to_transfer, format_amount_input, \ text2html from .utils.operators import JournalEntryOperator, JOURNAL_ENTRY_TYPE_TO_OP, \ get_journal_entry_op +from .. import db +from ..locale import lazy_gettext +from ..models import JournalEntry +from ..utils.cast import s +from ..utils.flash_errors import flash_form_errors +from ..utils.journal_entry_types import JournalEntryType +from ..utils.next_uri import inherit_next, or_next +from ..utils.permission import has_permission, can_view, can_edit +from ..utils.timezone import get_tz_today +from ..utils.user import get_current_user_pk bp: Blueprint = Blueprint("journal-entry", __name__) """The view blueprint for the journal entry management.""" diff --git a/src/accounting/models.py b/src/accounting/models.py index 1e5a849..a46022d 100644 --- a/src/accounting/models.py +++ b/src/accounting/models.py @@ -1,7 +1,7 @@ # The Mia! Accounting Project. # Author: imacat@mail.imacat.idv.tw (imacat), 2023/1/25 -# Copyright (c) 2023 imacat. +# Copyright (c) 2023-2026 imacat. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -30,9 +30,9 @@ from flask_babel import get_locale, get_babel from sqlalchemy import text from sqlalchemy.orm import Mapped, mapped_column -from accounting import db -from accounting.locale import gettext -from accounting.utils.user import user_cls, user_pk_column +from . import db +from .locale import gettext +from .utils.user import user_cls, user_pk_column class BaseAccount(db.Model): @@ -462,7 +462,7 @@ class Currency(db.Model): :return: True if the currency can be deleted, or False otherwise. """ - from accounting.template_globals import default_currency_code + from .template_globals import default_currency_code if self.code == default_currency_code(): return False return len(self.line_items) == 0 @@ -699,7 +699,7 @@ class JournalEntryLineItem(db.Model): :return: The string representation of the line item. """ if not hasattr(self, "__str"): - from accounting.template_filters import format_date, format_amount + from .template_filters import format_date, format_amount setattr(self, "__str", gettext("%(date)s %(description)s %(amount)s", date=format_date(self.journal_entry.date), diff --git a/src/accounting/option/forms.py b/src/accounting/option/forms.py index e588ba1..6be591a 100644 --- a/src/accounting/option/forms.py +++ b/src/accounting/option/forms.py @@ -1,7 +1,7 @@ # The Mia! Accounting Project. # Author: imacat@mail.imacat.idv.tw (imacat), 2023/3/22 -# Copyright (c) 2023 imacat. +# Copyright (c) 2023-2026 imacat. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -23,13 +23,13 @@ from flask_wtf import FlaskForm from wtforms import StringField, FieldList, FormField, IntegerField from wtforms.validators import DataRequired, ValidationError -from accounting.forms import ACCOUNT_REQUIRED, CurrencyExists, AccountExists, \ +from ..forms import ACCOUNT_REQUIRED, CurrencyExists, AccountExists, \ IsDebitAccount, IsCreditAccount -from accounting.locale import lazy_gettext -from accounting.models import Account -from accounting.utils.current_account import CurrentAccount -from accounting.utils.options import Options -from accounting.utils.strip_text import strip_text +from ..locale import lazy_gettext +from ..models import Account +from ..utils.current_account import CurrentAccount +from ..utils.options import Options +from ..utils.strip_text import strip_text class CurrentAccountExists: diff --git a/src/accounting/option/views.py b/src/accounting/option/views.py index 57b6c5c..32b5833 100644 --- a/src/accounting/option/views.py +++ b/src/accounting/option/views.py @@ -23,13 +23,13 @@ from flask import Blueprint, render_template, redirect, session, request, \ flash, url_for, Response from werkzeug.datastructures import ImmutableMultiDict -from accounting.locale import lazy_gettext -from accounting.utils.cast import s -from accounting.utils.flash_errors import flash_form_errors -from accounting.utils.next_uri import inherit_next -from accounting.utils.options import options -from accounting.utils.permission import has_permission, can_admin from .forms import OptionForm +from ..locale import lazy_gettext +from ..utils.cast import s +from ..utils.flash_errors import flash_form_errors +from ..utils.next_uri import inherit_next +from ..utils.options import options +from ..utils.permission import has_permission, can_admin bp: Blueprint = Blueprint("option", __name__) """The view blueprint for the currency management.""" diff --git a/src/accounting/report/converters.py b/src/accounting/report/converters.py index b8ebb86..9cb6632 100644 --- a/src/accounting/report/converters.py +++ b/src/accounting/report/converters.py @@ -1,7 +1,7 @@ # The Mia! Accounting Project. # Author: imacat@mail.imacat.idv.tw (imacat), 2023/3/3 -# Copyright (c) 2023 imacat. +# Copyright (c) 2023-2026 imacat. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -22,9 +22,9 @@ import re from flask import abort from werkzeug.routing import BaseConverter -from accounting.models import Account -from accounting.utils.current_account import CurrentAccount from .period import Period, get_period +from ..models import Account +from ..utils.current_account import CurrentAccount class PeriodConverter(BaseConverter): diff --git a/src/accounting/report/period/chooser.py b/src/accounting/report/period/chooser.py index ae300df..46e5531 100644 --- a/src/accounting/report/period/chooser.py +++ b/src/accounting/report/period/chooser.py @@ -1,7 +1,7 @@ # The Mia! Accounting Project. # Author: imacat@mail.imacat.idv.tw (imacat), 2023/3/4 -# Copyright (c) 2023-2024 imacat. +# Copyright (c) 2023-2026 imacat. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -23,11 +23,11 @@ This file is largely taken from the NanoParma ERP project, first written in import datetime as dt from collections.abc import Callable -from accounting.models import JournalEntry -from accounting.utils.timezone import get_tz_today from .period import Period from .shortcuts import ThisMonth, LastMonth, SinceLastMonth, ThisYear, \ LastYear, Today, Yesterday, AllTime, TemplatePeriod, YearPeriod +from ...models import JournalEntry +from ...utils.timezone import get_tz_today class PeriodChooser: diff --git a/src/accounting/report/period/description.py b/src/accounting/report/period/description.py index 2fae1e8..8dd2172 100644 --- a/src/accounting/report/period/description.py +++ b/src/accounting/report/period/description.py @@ -1,7 +1,7 @@ # The Mia! Accounting Project. # Author: imacat@mail.imacat.idv.tw (imacat), 2023/3/4 -# Copyright (c) 2023 imacat. +# Copyright (c) 2023-2026 imacat. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -19,7 +19,7 @@ """ import datetime as dt -from accounting.locale import gettext +from ...locale import gettext def get_desc(start: dt.date | None, end: dt.date | None) -> str: diff --git a/src/accounting/report/period/shortcuts.py b/src/accounting/report/period/shortcuts.py index 827cead..06769e0 100644 --- a/src/accounting/report/period/shortcuts.py +++ b/src/accounting/report/period/shortcuts.py @@ -1,7 +1,7 @@ # The Mia! Accounting Project. # Author: imacat@mail.imacat.idv.tw (imacat), 2023/3/4 -# Copyright (c) 2023-2024 imacat. +# Copyright (c) 2023-2026 imacat. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -19,10 +19,10 @@ """ import datetime as dt -from accounting.locale import gettext -from accounting.utils.timezone import get_tz_today from .month_end import month_end from .period import Period +from ...locale import gettext +from ...utils.timezone import get_tz_today class ThisMonth(Period): diff --git a/src/accounting/report/reports/balance_sheet.py b/src/accounting/report/reports/balance_sheet.py index 39ca2a8..cd79ce5 100644 --- a/src/accounting/report/reports/balance_sheet.py +++ b/src/accounting/report/reports/balance_sheet.py @@ -1,7 +1,7 @@ # The Mia! Accounting Project. # Author: imacat@mail.imacat.idv.tw (imacat), 2023/3/7 -# Copyright (c) 2023 imacat. +# Copyright (c) 2023-2026 imacat. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -22,20 +22,18 @@ from decimal import Decimal import sqlalchemy as sa from flask import render_template, Response -from accounting import db -from accounting.locale import gettext -from accounting.models import Currency, BaseAccount, Account, JournalEntry, \ +from ..period import Period, PeriodChooser +from ..utils.base_page_params import BasePageParams +from ..utils.base_report import BaseReport +from ..utils.csv_export import BaseCSVRow, csv_download, period_spec +from ..utils.option_link import OptionLink +from ..utils.report_chooser import ReportChooser +from ..utils.report_type import ReportType +from ..utils.urls import ledger_url, balance_sheet_url, income_statement_url +from ... import db +from ...locale import gettext +from ...models import Currency, BaseAccount, Account, JournalEntry, \ JournalEntryLineItem -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.report_chooser import ReportChooser -from accounting.report.utils.report_type import ReportType -from accounting.report.utils.urls import ledger_url, balance_sheet_url, \ - income_statement_url class ReportAccount: diff --git a/src/accounting/report/reports/income_expenses.py b/src/accounting/report/reports/income_expenses.py index 6412103..348c01e 100644 --- a/src/accounting/report/reports/income_expenses.py +++ b/src/accounting/report/reports/income_expenses.py @@ -1,7 +1,7 @@ # The Mia! Accounting Project. # Author: imacat@mail.imacat.idv.tw (imacat), 2023/3/7 -# Copyright (c) 2023 imacat. +# Copyright (c) 2023-2026 imacat. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -24,21 +24,19 @@ import sqlalchemy as sa from flask import url_for, render_template, Response from sqlalchemy.orm import selectinload -from accounting import db -from accounting.locale import gettext -from accounting.models import Currency, Account, JournalEntry, \ - JournalEntryLineItem -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.report_chooser import ReportChooser -from accounting.report.utils.report_type import ReportType -from accounting.report.utils.urls import income_expenses_url -from accounting.utils.current_account import CurrentAccount -from accounting.utils.pagination import Pagination +from ..period import Period, PeriodChooser +from ..utils.base_page_params import BasePageParams +from ..utils.base_report import BaseReport +from ..utils.csv_export import BaseCSVRow, csv_download, period_spec +from ..utils.option_link import OptionLink +from ..utils.report_chooser import ReportChooser +from ..utils.report_type import ReportType +from ..utils.urls import income_expenses_url +from ... import db +from ...locale import gettext +from ...models import Currency, Account, JournalEntry, JournalEntryLineItem +from ...utils.current_account import CurrentAccount +from ...utils.pagination import Pagination class ReportLineItem: diff --git a/src/accounting/report/reports/income_statement.py b/src/accounting/report/reports/income_statement.py index 8af89d7..ad1b6b1 100644 --- a/src/accounting/report/reports/income_statement.py +++ b/src/accounting/report/reports/income_statement.py @@ -1,7 +1,7 @@ # The Mia! Accounting Project. # Author: imacat@mail.imacat.idv.tw (imacat), 2023/3/7 -# Copyright (c) 2023 imacat. +# Copyright (c) 2023-2026 imacat. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -22,19 +22,18 @@ from decimal import Decimal import sqlalchemy as sa from flask import render_template, Response -from accounting import db -from accounting.locale import gettext -from accounting.models import Currency, BaseAccount, Account, JournalEntry, \ +from ..period import Period, PeriodChooser +from ..utils.base_page_params import BasePageParams +from ..utils.base_report import BaseReport +from ..utils.csv_export import BaseCSVRow, csv_download, period_spec +from ..utils.option_link import OptionLink +from ..utils.report_chooser import ReportChooser +from ..utils.report_type import ReportType +from ..utils.urls import ledger_url, income_statement_url +from ... import db +from ...locale import gettext +from ...models import Currency, BaseAccount, Account, JournalEntry, \ JournalEntryLineItem -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.report_chooser import ReportChooser -from accounting.report.utils.report_type import ReportType -from accounting.report.utils.urls import ledger_url, income_statement_url class ReportAccount: diff --git a/src/accounting/report/reports/journal.py b/src/accounting/report/reports/journal.py index 470b2d3..baba68b 100644 --- a/src/accounting/report/reports/journal.py +++ b/src/accounting/report/reports/journal.py @@ -1,7 +1,7 @@ # The Mia! Accounting Project. # Author: imacat@mail.imacat.idv.tw (imacat), 2023/3/7 -# Copyright (c) 2023 imacat. +# Copyright (c) 2023-2026 imacat. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -24,18 +24,16 @@ import sqlalchemy as sa from flask import render_template, Response from sqlalchemy.orm import selectinload -from accounting.locale import gettext -from accounting.models import Currency, Account, JournalEntry, \ - JournalEntryLineItem -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.report_chooser import ReportChooser -from accounting.report.utils.report_type import ReportType -from accounting.report.utils.urls import journal_url -from accounting.utils.pagination import Pagination +from ..period import Period, PeriodChooser +from ..utils.base_page_params import BasePageParams +from ..utils.base_report import BaseReport +from ..utils.csv_export import BaseCSVRow, csv_download, period_spec +from ..utils.report_chooser import ReportChooser +from ..utils.report_type import ReportType +from ..utils.urls import journal_url +from ...locale import gettext +from ...models import Currency, Account, JournalEntry, JournalEntryLineItem +from ...utils.pagination import Pagination class ReportLineItem: diff --git a/src/accounting/report/reports/ledger.py b/src/accounting/report/reports/ledger.py index 1175145..cd3c8c9 100644 --- a/src/accounting/report/reports/ledger.py +++ b/src/accounting/report/reports/ledger.py @@ -1,7 +1,7 @@ # The Mia! Accounting Project. # Author: imacat@mail.imacat.idv.tw (imacat), 2023/3/7 -# Copyright (c) 2023 imacat. +# Copyright (c) 2023-2026 imacat. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -24,20 +24,18 @@ import sqlalchemy as sa from flask import url_for, render_template, Response from sqlalchemy.orm import selectinload -from accounting import db -from accounting.locale import gettext -from accounting.models import Currency, Account, JournalEntry, \ - JournalEntryLineItem -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.report_chooser import ReportChooser -from accounting.report.utils.report_type import ReportType -from accounting.report.utils.urls import ledger_url -from accounting.utils.pagination import Pagination +from ..period import Period, PeriodChooser +from ..utils.base_page_params import BasePageParams +from ..utils.base_report import BaseReport +from ..utils.csv_export import BaseCSVRow, csv_download, period_spec +from ..utils.option_link import OptionLink +from ..utils.report_chooser import ReportChooser +from ..utils.report_type import ReportType +from ..utils.urls import ledger_url +from ... import db +from ...locale import gettext +from ...models import Currency, Account, JournalEntry, JournalEntryLineItem +from ...utils.pagination import Pagination class ReportLineItem: diff --git a/src/accounting/report/reports/search.py b/src/accounting/report/reports/search.py index e326b44..e11860f 100644 --- a/src/accounting/report/reports/search.py +++ b/src/accounting/report/reports/search.py @@ -1,7 +1,7 @@ # The Mia! Accounting Project. # Author: imacat@mail.imacat.idv.tw (imacat), 2023/3/8 -# Copyright (c) 2023 imacat. +# Copyright (c) 2023-2026 imacat. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -24,17 +24,17 @@ import sqlalchemy as sa from flask import Response, render_template, request from sqlalchemy.orm import selectinload -from accounting.locale import gettext -from accounting.models import Currency, CurrencyL10n, Account, AccountL10n, \ - JournalEntry, JournalEntryLineItem -from accounting.report.utils.base_page_params import BasePageParams -from accounting.report.utils.base_report import BaseReport -from accounting.report.utils.csv_export import csv_download -from accounting.report.utils.report_chooser import ReportChooser -from accounting.report.utils.report_type import ReportType -from accounting.utils.pagination import Pagination -from accounting.utils.query import parse_query_keywords from .journal import get_csv_rows +from ..utils.base_page_params import BasePageParams +from ..utils.base_report import BaseReport +from ..utils.csv_export import csv_download +from ..utils.report_chooser import ReportChooser +from ..utils.report_type import ReportType +from ...locale import gettext +from ...models import Currency, CurrencyL10n, Account, AccountL10n, \ + JournalEntry, JournalEntryLineItem +from ...utils.pagination import Pagination +from ...utils.query import parse_query_keywords class LineItemCollector: diff --git a/src/accounting/report/reports/trial_balance.py b/src/accounting/report/reports/trial_balance.py index 82cd7b1..64c2aff 100644 --- a/src/accounting/report/reports/trial_balance.py +++ b/src/accounting/report/reports/trial_balance.py @@ -1,7 +1,7 @@ # The Mia! Accounting Project. # Author: imacat@mail.imacat.idv.tw (imacat), 2023/3/7 -# Copyright (c) 2023 imacat. +# Copyright (c) 2023-2026 imacat. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -22,19 +22,17 @@ from decimal import Decimal import sqlalchemy as sa from flask import Response, render_template -from accounting import db -from accounting.locale import gettext -from accounting.models import Currency, Account, JournalEntry, \ - JournalEntryLineItem -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.report_chooser import ReportChooser -from accounting.report.utils.report_type import ReportType -from accounting.report.utils.urls import ledger_url, trial_balance_url +from ..period import Period, PeriodChooser +from ..utils.base_page_params import BasePageParams +from ..utils.base_report import BaseReport +from ..utils.csv_export import BaseCSVRow, csv_download, period_spec +from ..utils.option_link import OptionLink +from ..utils.report_chooser import ReportChooser +from ..utils.report_type import ReportType +from ..utils.urls import ledger_url, trial_balance_url +from ... import db +from ...locale import gettext +from ...models import Currency, Account, JournalEntry, JournalEntryLineItem class ReportAccount: diff --git a/src/accounting/report/reports/unapplied.py b/src/accounting/report/reports/unapplied.py index 815c936..1f59513 100644 --- a/src/accounting/report/reports/unapplied.py +++ b/src/accounting/report/reports/unapplied.py @@ -1,7 +1,7 @@ # The Mia! Accounting Project. # Author: imacat@mail.imacat.idv.tw (imacat), 2023/4/7 -# Copyright (c) 2023 imacat. +# Copyright (c) 2023-2026 imacat. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -23,19 +23,17 @@ from decimal import Decimal from flask import render_template, Response from sqlalchemy.orm import selectinload -from accounting.locale import gettext -from accounting.models import Currency, Account, JournalEntry, \ - JournalEntryLineItem -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 -from accounting.report.utils.option_link import OptionLink -from accounting.report.utils.report_chooser import ReportChooser -from accounting.report.utils.report_type import ReportType -from accounting.report.utils.unapplied import get_accounts_with_unapplied, \ - get_net_balances -from accounting.report.utils.urls import unapplied_url -from accounting.utils.pagination import Pagination +from ..utils.base_page_params import BasePageParams +from ..utils.base_report import BaseReport +from ..utils.csv_export import BaseCSVRow, csv_download +from ..utils.option_link import OptionLink +from ..utils.report_chooser import ReportChooser +from ..utils.report_type import ReportType +from ..utils.unapplied import get_accounts_with_unapplied, get_net_balances +from ..utils.urls import unapplied_url +from ...locale import gettext +from ...models import Currency, Account, JournalEntry, JournalEntryLineItem +from ...utils.pagination import Pagination class CSVRow(BaseCSVRow): diff --git a/src/accounting/report/reports/unapplied_accounts.py b/src/accounting/report/reports/unapplied_accounts.py index 99a22c4..cb596e7 100644 --- a/src/accounting/report/reports/unapplied_accounts.py +++ b/src/accounting/report/reports/unapplied_accounts.py @@ -1,7 +1,7 @@ # The Mia! Accounting Project. # Author: imacat@mail.imacat.idv.tw (imacat), 2023/4/7 -# Copyright (c) 2023 imacat. +# Copyright (c) 2023-2026 imacat. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -22,16 +22,16 @@ from decimal import Decimal from flask import render_template, Response -from accounting.locale import gettext -from accounting.models import Currency, Account -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 -from accounting.report.utils.option_link import OptionLink -from accounting.report.utils.report_chooser import ReportChooser -from accounting.report.utils.report_type import ReportType -from accounting.report.utils.unapplied import get_accounts_with_unapplied -from accounting.report.utils.urls import unapplied_url +from ..utils.base_page_params import BasePageParams +from ..utils.base_report import BaseReport +from ..utils.csv_export import BaseCSVRow, csv_download +from ..utils.option_link import OptionLink +from ..utils.report_chooser import ReportChooser +from ..utils.report_type import ReportType +from ..utils.unapplied import get_accounts_with_unapplied +from ..utils.urls import unapplied_url +from ...locale import gettext +from ...models import Currency, Account class CSVRow(BaseCSVRow): diff --git a/src/accounting/report/reports/unmatched.py b/src/accounting/report/reports/unmatched.py index d4fac42..dd9fbbf 100644 --- a/src/accounting/report/reports/unmatched.py +++ b/src/accounting/report/reports/unmatched.py @@ -1,7 +1,7 @@ # The Mia! Accounting Project. # Author: imacat@mail.imacat.idv.tw (imacat), 2023/4/17 -# Copyright (c) 2023 imacat. +# Copyright (c) 2023-2026 imacat. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -23,18 +23,18 @@ from decimal import Decimal from flask import render_template, Response from flask_babel import LazyString -from accounting.locale import gettext -from accounting.models import Currency, Account, JournalEntryLineItem -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 -from accounting.report.utils.offset_matcher import OffsetMatcher, OffsetPair -from accounting.report.utils.option_link import OptionLink -from accounting.report.utils.report_chooser import ReportChooser -from accounting.report.utils.report_type import ReportType -from accounting.report.utils.unmatched import get_accounts_with_unmatched -from accounting.report.utils.urls import unmatched_url -from accounting.utils.pagination import Pagination +from ..utils.base_page_params import BasePageParams +from ..utils.base_report import BaseReport +from ..utils.csv_export import BaseCSVRow, csv_download +from ..utils.offset_matcher import OffsetMatcher, OffsetPair +from ..utils.option_link import OptionLink +from ..utils.report_chooser import ReportChooser +from ..utils.report_type import ReportType +from ..utils.unmatched import get_accounts_with_unmatched +from ..utils.urls import unmatched_url +from ...locale import gettext +from ...models import Currency, Account, JournalEntryLineItem +from ...utils.pagination import Pagination class CSVRow(BaseCSVRow): diff --git a/src/accounting/report/reports/unmatched_accounts.py b/src/accounting/report/reports/unmatched_accounts.py index 4a3d6cb..8dabfb4 100644 --- a/src/accounting/report/reports/unmatched_accounts.py +++ b/src/accounting/report/reports/unmatched_accounts.py @@ -1,7 +1,7 @@ # The Mia! Accounting Project. # Author: imacat@mail.imacat.idv.tw (imacat), 2023/4/17 -# Copyright (c) 2023 imacat. +# Copyright (c) 2023-2026 imacat. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -22,16 +22,16 @@ from decimal import Decimal from flask import render_template, Response -from accounting.locale import gettext -from accounting.models import Currency, Account -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 -from accounting.report.utils.option_link import OptionLink -from accounting.report.utils.report_chooser import ReportChooser -from accounting.report.utils.report_type import ReportType -from accounting.report.utils.unmatched import get_accounts_with_unmatched -from accounting.report.utils.urls import unmatched_url +from ..utils.base_page_params import BasePageParams +from ..utils.base_report import BaseReport +from ..utils.csv_export import BaseCSVRow, csv_download +from ..utils.option_link import OptionLink +from ..utils.report_chooser import ReportChooser +from ..utils.report_type import ReportType +from ..utils.unmatched import get_accounts_with_unmatched +from ..utils.urls import unmatched_url +from ...locale import gettext +from ...models import Currency, Account class CSVRow(BaseCSVRow): diff --git a/src/accounting/report/template_filters.py b/src/accounting/report/template_filters.py index f607bb6..5f1faf1 100644 --- a/src/accounting/report/template_filters.py +++ b/src/accounting/report/template_filters.py @@ -1,7 +1,7 @@ # The Mia! Accounting Project. # Author: imacat@mail.imacat.idv.tw (imacat), 2023/3/7 -# Copyright (c) 2023 imacat. +# Copyright (c) 2023-2026 imacat. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -19,7 +19,7 @@ """ from decimal import Decimal -from accounting.template_filters import format_amount as core_format_amount +from ..template_filters import format_amount as core_format_amount def format_amount(value: Decimal | None) -> str | None: diff --git a/src/accounting/report/utils/base_page_params.py b/src/accounting/report/utils/base_page_params.py index f60766b..e0b95b2 100644 --- a/src/accounting/report/utils/base_page_params.py +++ b/src/accounting/report/utils/base_page_params.py @@ -1,7 +1,7 @@ # The Mia! Accounting Project. # Author: imacat@mail.imacat.idv.tw (imacat), 2023/3/6 -# Copyright (c) 2023 imacat. +# Copyright (c) 2023-2026 imacat. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -26,11 +26,11 @@ from urllib.parse import urlparse, ParseResult, parse_qsl, urlencode, \ import sqlalchemy as sa from flask import request -from accounting import db -from accounting.models import Currency, JournalEntryLineItem -from accounting.utils.journal_entry_types import JournalEntryType from .option_link import OptionLink from .report_chooser import ReportChooser +from ... import db +from ...models import Currency, JournalEntryLineItem +from ...utils.journal_entry_types import JournalEntryType class BasePageParams(ABC): diff --git a/src/accounting/report/utils/csv_export.py b/src/accounting/report/utils/csv_export.py index 81df94b..c419f9d 100644 --- a/src/accounting/report/utils/csv_export.py +++ b/src/accounting/report/utils/csv_export.py @@ -1,7 +1,7 @@ # The Mia! Accounting Project. # Author: imacat@mail.imacat.idv.tw (imacat), 2023/3/7 -# Copyright (c) 2023 imacat. +# Copyright (c) 2023-2026 imacat. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -26,7 +26,7 @@ from urllib.parse import quote from flask import Response -from accounting.report.period import Period +from ..period import Period class BaseCSVRow(ABC): diff --git a/src/accounting/report/utils/offset_matcher.py b/src/accounting/report/utils/offset_matcher.py index e244f85..9f21ae9 100644 --- a/src/accounting/report/utils/offset_matcher.py +++ b/src/accounting/report/utils/offset_matcher.py @@ -1,7 +1,7 @@ # The Mia! Accounting Project. # Author: imacat@mail.imacat.idv.tw (imacat), 2023/4/8 -# Copyright (c) 2023 imacat. +# Copyright (c) 2023-2026 imacat. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -23,10 +23,9 @@ import sqlalchemy as sa from flask_babel import LazyString from sqlalchemy.orm import selectinload -from accounting.locale import lazy_gettext -from accounting.models import Currency, Account, JournalEntry, \ - JournalEntryLineItem -from accounting.report.utils.unapplied import get_net_balances +from ..utils.unapplied import get_net_balances +from ...locale import lazy_gettext +from ...models import Currency, Account, JournalEntry, JournalEntryLineItem class OffsetPair: diff --git a/src/accounting/report/utils/report_chooser.py b/src/accounting/report/utils/report_chooser.py index 57da226..17c6300 100644 --- a/src/accounting/report/utils/report_chooser.py +++ b/src/accounting/report/utils/report_chooser.py @@ -1,7 +1,7 @@ # The Mia! Accounting Project. # Author: imacat@mail.imacat.idv.tw (imacat), 2023/3/4 -# Copyright (c) 2023 imacat. +# Copyright (c) 2023-2026 imacat. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -25,18 +25,18 @@ from collections.abc import Iterator 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, get_period -from accounting.template_globals import default_currency_code -from accounting.utils.current_account import CurrentAccount -from accounting.utils.permission import can_edit from .option_link import OptionLink from .report_type import ReportType from .urls import journal_url, ledger_url, income_expenses_url, \ trial_balance_url, income_statement_url, balance_sheet_url, \ unapplied_url, unmatched_url +from ..period import Period, get_period +from ... import db +from ...locale import gettext +from ...models import Currency, Account +from ...template_globals import default_currency_code +from ...utils.current_account import CurrentAccount +from ...utils.permission import can_edit class ReportChooser: diff --git a/src/accounting/report/utils/unapplied.py b/src/accounting/report/utils/unapplied.py index a7d359a..8253d0b 100644 --- a/src/accounting/report/utils/unapplied.py +++ b/src/accounting/report/utils/unapplied.py @@ -1,7 +1,7 @@ # The Mia! Accounting Project. # Author: imacat@mail.imacat.idv.tw (imacat), 2023/4/7 -# Copyright (c) 2023 imacat. +# Copyright (c) 2023-2026 imacat. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -21,10 +21,9 @@ from decimal import Decimal import sqlalchemy as sa -from accounting import db -from accounting.models import Currency, Account, JournalEntry, \ - JournalEntryLineItem -from accounting.utils.offset_alias import offset_alias +from ... import db +from ...models import Currency, Account, JournalEntry, JournalEntryLineItem +from ...utils.offset_alias import offset_alias def get_accounts_with_unapplied(currency: Currency) -> list[Account]: diff --git a/src/accounting/report/utils/unmatched.py b/src/accounting/report/utils/unmatched.py index 619f485..21bc593 100644 --- a/src/accounting/report/utils/unmatched.py +++ b/src/accounting/report/utils/unmatched.py @@ -1,7 +1,7 @@ # The Mia! Accounting Project. # Author: imacat@mail.imacat.idv.tw (imacat), 2023/4/8 -# Copyright (c) 2023 imacat. +# Copyright (c) 2023-2026 imacat. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -19,9 +19,8 @@ """ import sqlalchemy as sa -from accounting import db -from accounting.models import Currency, Account, JournalEntry, \ - JournalEntryLineItem +from ... import db +from ...models import Currency, Account, JournalEntry, JournalEntryLineItem def get_accounts_with_unmatched(currency: Currency) -> list[Account]: diff --git a/src/accounting/report/utils/urls.py b/src/accounting/report/utils/urls.py index 7e8f9bb..ae5d147 100644 --- a/src/accounting/report/utils/urls.py +++ b/src/accounting/report/utils/urls.py @@ -1,7 +1,7 @@ # The Mia! Accounting Project. # Author: imacat@mail.imacat.idv.tw (imacat), 2023/3/9 -# Copyright (c) 2023 imacat. +# Copyright (c) 2023-2026 imacat. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -19,11 +19,11 @@ """ from flask import url_for -from accounting.models import Currency, Account -from accounting.report.period import Period -from accounting.template_globals import default_currency_code -from accounting.utils.current_account import CurrentAccount -from accounting.utils.options import options +from ...models import Currency, Account +from ...report.period import Period +from ...template_globals import default_currency_code +from ...utils.current_account import CurrentAccount +from ...utils.options import options def journal_url(period: Period) \ diff --git a/src/accounting/report/views.py b/src/accounting/report/views.py index 96a557e..137383b 100644 --- a/src/accounting/report/views.py +++ b/src/accounting/report/views.py @@ -19,15 +19,6 @@ """ from flask import Blueprint, request, Response, redirect, flash -from accounting import db -from accounting.locale import lazy_gettext -from accounting.models import Currency, Account -from accounting.template_globals import default_currency_code -from accounting.utils.cast import s -from accounting.utils.current_account import CurrentAccount -from accounting.utils.next_uri import or_next -from accounting.utils.options import options -from accounting.utils.permission import has_permission, can_view, can_edit from .period import Period, get_period from .reports import Journal, Ledger, IncomeExpenses, TrialBalance, \ IncomeStatement, BalanceSheet, Search @@ -38,6 +29,15 @@ from .reports.unmatched_accounts import AccountsWithUnmatchedOffsets from .template_filters import format_amount from .utils.offset_matcher import OffsetMatcher from .utils.urls import unmatched_url +from .. import db +from ..locale import lazy_gettext +from ..models import Currency, Account +from ..template_globals import default_currency_code +from ..utils.cast import s +from ..utils.current_account import CurrentAccount +from ..utils.next_uri import or_next +from ..utils.options import options +from ..utils.permission import has_permission, can_view, can_edit bp: Blueprint = Blueprint("accounting-report", __name__) """The view blueprint for the reports.""" diff --git a/src/accounting/template_filters.py b/src/accounting/template_filters.py index 1faa62d..6ec8809 100644 --- a/src/accounting/template_filters.py +++ b/src/accounting/template_filters.py @@ -1,7 +1,7 @@ # The Mia! Accounting Project. # Author: imacat@mail.imacat.idv.tw (imacat), 2023/2/25 -# Copyright (c) 2023-2024 imacat. +# Copyright (c) 2023-2026 imacat. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -23,8 +23,8 @@ from typing import Any from flask_babel import get_locale -from accounting.locale import gettext -from accounting.utils.timezone import get_tz_today +from .locale import gettext +from .utils.timezone import get_tz_today def format_amount(value: Decimal | None) -> str | None: diff --git a/src/accounting/template_globals.py b/src/accounting/template_globals.py index 8e7f0e1..a47ec97 100644 --- a/src/accounting/template_globals.py +++ b/src/accounting/template_globals.py @@ -1,7 +1,7 @@ # The Mia! Accounting Project. # Author: imacat@mail.imacat.idv.tw (imacat), 2023/3/3 -# Copyright (c) 2023 imacat. +# Copyright (c) 2023-2026 imacat. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,8 +17,8 @@ """The template globals. """ -from accounting.models import Currency -from accounting.utils.options import options +from .models import Currency +from .utils.options import options def currency_options() -> list[Currency]: diff --git a/src/accounting/utils/current_account.py b/src/accounting/utils/current_account.py index 71d41f1..c63d90c 100644 --- a/src/accounting/utils/current_account.py +++ b/src/accounting/utils/current_account.py @@ -1,7 +1,7 @@ # The Mia! Accounting Project. # Author: imacat@mail.imacat.idv.tw (imacat), 2023/3/22 -# Copyright (c) 2023 imacat. +# Copyright (c) 2023-2026 imacat. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -21,8 +21,8 @@ from typing import Self import sqlalchemy as sa -from accounting.locale import gettext -from accounting.models import Account +from ..locale import gettext +from ..models import Account class CurrentAccount: diff --git a/src/accounting/utils/offset_alias.py b/src/accounting/utils/offset_alias.py index bd32225..2cf3b86 100644 --- a/src/accounting/utils/offset_alias.py +++ b/src/accounting/utils/offset_alias.py @@ -1,7 +1,7 @@ # The Mia! Accounting Project. # Author: imacat@mail.imacat.idv.tw (imacat), 2023/3/15 -# Copyright (c) 2023 imacat. +# Copyright (c) 2023-2026 imacat. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -21,7 +21,7 @@ from typing import Any import sqlalchemy as sa -from accounting.models import JournalEntryLineItem +from ..models import JournalEntryLineItem def offset_alias() -> sa.Alias: diff --git a/src/accounting/utils/options.py b/src/accounting/utils/options.py index 9e032b6..02eb11e 100644 --- a/src/accounting/utils/options.py +++ b/src/accounting/utils/options.py @@ -1,7 +1,7 @@ # The Mia! Accounting Project. # Author: imacat@mail.imacat.idv.tw (imacat), 2023/3/22 -# Copyright (c) 2023 imacat. +# Copyright (c) 2023-2026 imacat. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -21,10 +21,10 @@ import json import sqlalchemy as sa -from accounting import db -from accounting.models import Option, Account, Currency -from accounting.utils.current_account import CurrentAccount -from accounting.utils.user import get_current_user_pk +from .current_account import CurrentAccount +from .user import get_current_user_pk +from .. import db +from ..models import Option, Account, Currency class RecurringItem: diff --git a/src/accounting/utils/pagination.py b/src/accounting/utils/pagination.py index b765527..59fd99c 100644 --- a/src/accounting/utils/pagination.py +++ b/src/accounting/utils/pagination.py @@ -1,7 +1,7 @@ # The Mia! Accounting Project. # Author: imacat@mail.imacat.idv.tw (imacat), 2023/1/25 -# Copyright (c) 2023-2024 imacat. +# Copyright (c) 2023-2026 imacat. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -25,7 +25,7 @@ from urllib.parse import urlparse, parse_qsl, urlencode, urlunparse, \ from flask import request from werkzeug.routing import RequestRedirect -from accounting.locale import pgettext +from ..locale import pgettext class Link: diff --git a/src/accounting/utils/permission.py b/src/accounting/utils/permission.py index d8f17e2..36f15e9 100644 --- a/src/accounting/utils/permission.py +++ b/src/accounting/utils/permission.py @@ -1,7 +1,7 @@ # The Mia! Accounting Project. # Author: imacat@mail.imacat.idv.tw (imacat), 2023/1/25 -# Copyright (c) 2023 imacat. +# Copyright (c) 2023-2026 imacat. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -23,7 +23,7 @@ from collections.abc import Callable from flask import abort, Blueprint, Response -from accounting.utils.user import get_current_user, UserUtilityInterface +from .user import get_current_user, UserUtilityInterface def has_permission(rule: Callable[[], bool]) -> Callable: diff --git a/src/accounting/utils/query.py b/src/accounting/utils/query.py index c40c965..d95ef27 100644 --- a/src/accounting/utils/query.py +++ b/src/accounting/utils/query.py @@ -1,7 +1,7 @@ # The Mia! Accounting Project. # Author: imacat@mail.imacat.idv.tw (imacat), 2023/1/25 -# Copyright (c) 2023 imacat. +# Copyright (c) 2023-2026 imacat. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -21,8 +21,6 @@ This module should not import any other module from the application. """ import re -from typing_extensions import assert_type - def parse_query_keywords(q: str | None) -> list[str]: """Returns the query keywords by the query parameter. diff --git a/src/accounting/utils/random_id.py b/src/accounting/utils/random_id.py index 382286f..e9ec95c 100644 --- a/src/accounting/utils/random_id.py +++ b/src/accounting/utils/random_id.py @@ -1,7 +1,7 @@ # The Mia! Accounting Project. # Author: imacat@mail.imacat.idv.tw (imacat), 2023/1/30 -# Copyright (c) 2023 imacat. +# Copyright (c) 2023-2026 imacat. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ This module should not import any other module from the application. from secrets import randbelow from typing import Type -from accounting import db +from .. import db def new_id(cls: Type[db.Model]): diff --git a/src/accounting/utils/timezone.py b/src/accounting/utils/timezone.py index 8cdda19..2dcd23d 100644 --- a/src/accounting/utils/timezone.py +++ b/src/accounting/utils/timezone.py @@ -1,7 +1,7 @@ # The Mia! Accounting Project. # Author: imacat@mail.imacat.idv.tw (imacat), 2024/6/4 -# Copyright (c) 2024 imacat. +# Copyright (c) 2024-2026 imacat. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -19,7 +19,6 @@ This module should not import any other module from the application. """ - import datetime as dt import pytz